Skip to content

Instantly share code, notes, and snippets.

@chrisn
chrisn / prettify_json
Last active October 10, 2015 19:07
Prettify JSON
cat input.json | python -mjson.tool > output.json
@chrisn
chrisn / interfaces
Created October 8, 2012 11:34
Multicast network config
auto lo
iface lo inet loopback
# Added these lines:
up ifconfig lo multicast
up route add 232.0.0.1 dev lo
@chrisn
chrisn / hex_dump
Last active December 17, 2015 23:59
Dump a file as hexadecimal
od -t x1 -A x -v <filename>
@chrisn
chrisn / list_open_ports
Created June 12, 2013 15:22
List open ports
lsof -i -P
@chrisn
chrisn / curl_post_json
Created June 14, 2013 14:58
Post JSON data from a file to a url
curl <url> -H "Content-Type: application/json" --data @<filename>
@chrisn
chrisn / connect_pop3
Created November 2, 2013 23:09
Connect to POP3 server over SSL using openssl
openssl s_client -crlf -ign_eof -connect <pop3-server-address>:995
@chrisn
chrisn / popen3_test
Last active March 2, 2023 08:48
Ruby example of using Open3.popen3 with a select loop to read a child process's standard output and standard error streams.
#!/usr/bin/env ruby
require 'open3'
# Returns true if all files are EOF
#
def all_eof(files)
files.find { |f| !f.eof }.nil?
end
@chrisn
chrisn / Preferences.sublime-settings
Created November 15, 2013 22:30
My Sublime Text 2 user settings
{
// Controls auto pairing of quotes, brackets etc
"auto_match_enabled": false,
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
// Set to true to ensure the last line of the file ends in a newline
// character when saving
"ensure_newline_at_eof_on_save": true,
@chrisn
chrisn / .gitconfig
Last active December 29, 2015 05:09
Git configuration
[alias]
st = status
dif = diff
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
wd = diff --word-diff
[color]
ui = true
@chrisn
chrisn / robocopy_backup
Created December 26, 2013 21:05
robocopy command to backup to a shared drive
robocopy D:\ Z:\BackupDir /MIR /XD "$RECYCLE.BIN" "System Volume Information" /FFT