Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / list_open_ports
Created June 12, 2013 15:22
List open ports
lsof -i -P
@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 / 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 / prettify_json
Last active October 10, 2015 19:07
Prettify JSON
cat input.json | python -mjson.tool > output.json