Skip to content

Instantly share code, notes, and snippets.

View samwho's full-sized avatar
🦀
Still in love with Rust.

Sam Rose samwho

🦀
Still in love with Rust.
View GitHub Profile

Keybase proof

I hereby claim:

  • I am samwho on github.
  • I am samwho (https://keybase.io/samwho) on keybase.
  • I have a public key whose fingerprint is BCFF 3E0B 91E0 6AD7 330B FA5B 589B 3CBE 7241 6055

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am samwho on github.
  • I am samrose (https://keybase.io/samrose) on keybase.
  • I have a public key ASCZ1DA2EUL9jDrJMgw5O5hwMPziNYxxzlhmtFxbRTCqBgo

To claim this, I am signing this object:

import logging
import socket
import string
from StringIO import StringIO
logging.getLogger().setLevel(logging.INFO)
class HttpRequest:
__slots__ = ['verb', 'path', 'protocol', 'headers', 'body']
def __init__(self, verb, path, protocol, headers, body):
#include <errno.h>
#include <error.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/capability.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
#include <sys/reg.h>
This file has been truncated, but you can view the full file.
INFO global: Vagrant version: 1.9.0
INFO global: Ruby version: 2.2.5
INFO global: RubyGems version: 2.4.5.1
INFO global: VAGRANT_EXECUTABLE="C:\\HashiCorp\\Vagrant\\embedded\\gems\\gems\\vagrant-1.9.0\\bin\\vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="C:\\HashiCorp\\Vagrant\\embedded"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_LOG="debug"
INFO global: VAGRANT_OLD_ENV_ACLOCAL_PATH="C:\\Program Files\\Git\\mingw64\\share\\aclocal;C:\\Program Files\\Git\\usr\\share\\aclocal"
INFO global: VAGRANT_OLD_ENV_ALLUSERSPROFILE="C:\\ProgramData"
@samwho
samwho / symbols.rb
Created December 15, 2013 20:48
Know your symbols!
# Ruby creates symbols at many different points in execution. Symbols occupy
# between 4 and 8 bytes in memory. Check using this code:
#
# #include <ruby/ruby.h>
# #include <stdio.h>
#
# int main(int argc, char* argv[]) {
# printf("%d\n", sizeof(ID));
# return 0;
# }
@samwho
samwho / random_regex.rb
Created October 30, 2013 18:15
/dev/random regexes
devrand = File.open("/dev/random", 'r')
valid = 0
invalid = 0
at_exit do
puts "\n\n\n\n#{valid}/#{valid + invalid}"
end
while chunk = devrand.read(64)
@samwho
samwho / test_interspersity.rb
Created August 5, 2013 13:57
Interspersity test
def test_interspersity array
# Calculate the ideal average distance between elements by summing how many of
# each element exist and then dividing the length of the array by that number.
ideal_avg_distance = Hash.new(0)
array.each { |elem| ideal_avg_distance[elem] += 1 }
ideal_avg_distance.keys.each do |k|
ideal_avg_distance[k] = array.length.to_f / ideal_avg_distance[k]
end
# Gather up all of the indices that each element appears at.
@samwho
samwho / strings.rb
Created June 16, 2013 17:18
Looking for expletives in Mac OSX binary files.
WORDLIST = [
"fuck",
"shit",
"cunt",
"wtf",
"wank",
"crap",
"hell",
"lame",
"rubbish",
@samwho
samwho / mandom.rb
Last active December 12, 2015 07:59
Short Ruby script to open a man page at random.
man_pages = `manpath`.chomp.split(':').inject([]) do |memo, path|
memo += Dir[File.join(path, 'man*', '*')]
end.select { |path| path.match(/.*?\.[1-9]$/) }
exec "man #{man_pages[rand(man_pages.length)]}"