Skip to content

Instantly share code, notes, and snippets.

@danvideo
danvideo / web-servers.md
Created January 21, 2020 09:11 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@danvideo
danvideo / curl.md
Created December 4, 2019 15:03 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@danvideo
danvideo / delete_git_submodule.md
Created October 23, 2019 08:11 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@danvideo
danvideo / jenkins-delete-builds.groovy
Created September 16, 2019 12:00 — forked from jbasila/jenkins-delete-builds.groovy
Jenkins: Delete older builds
// run this on the master:
// $ du -sk MAG-* |sort -rn|head -20 | while read _line ; do _ar=( ${_line} ); echo -n "\"$(cat ${_ar[1]}/name-utf8.txt)\", "; done ;echo ""
_array=[ ]
_array.each {
JOB_NAME="Magnifier/${it}"
KEEP_LAST_NUM_OF_BUILDS=2
Jenkins.instance.getItemByFullName("${JOB_NAME}").builds.findAll { true }.each {
if (KEEP_LAST_NUM_OF_BUILDS) {
@danvideo
danvideo / kube-registry.yaml
Created January 25, 2018 12:27 — forked from coco98/kube-registry.yaml
Docker registry on minikube
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1
@danvideo
danvideo / README-Template.md
Created April 5, 2017 15:46 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@danvideo
danvideo / Ruby: using Timeout, TCPServer, socket, net,ssh, pcaplet(packet analysis).rb using Timeout, TCPServer, socket, net,ssh, pcaplet(packet analysis)/http#practical ruby for system administrator
require "socket"
socket = TCPSocket.open("www.theonion.com", "80")
TCPSocket.open("www.theonion.com", 80) do |socket|
socket.puts "GET / HTTP/1.0\n\n"
puts socket.read
end
@danvideo
danvideo / gist:47cf9e6fd3ec68faa77507bface41549
Created December 26, 2016 10:11 — forked from TeWu/gist:1234573
TCP client and multithreaded server in 14 lines of Ruby code

TCP client and multithreaded server in 14 lines of Ruby code

Server:

require "socket"
server = TCPServer.open(2626)
loop do
	Thread.fork(server.accept) do |client| 
 client.puts("Hello, I'm Ruby TCP server", "I'm disconnecting, bye :*")
@danvideo
danvideo / tcp_server.rb
Created December 26, 2016 10:10 — forked from sergiocampama/tcp_server.rb
Ruby TCP Server
require 'socket'
server = TCPServer.open(3010) # Socket to listen on port
loop do # Servers run forever
Thread.start(server.accept) do |client|
puts "client connected"
#do stuff
end
end
@danvideo
danvideo / echo.rb
Created December 26, 2016 10:10 — forked from kyanny/echo.rb
Ruby socket TCPServer echo server
require 'socket'
gs = TCPServer.open(0)
socks = [gs]
addr = gs.addr
addr.shift
puts "server is on #{addr.join(':')}"
while true
nsock = select(socks)