Skip to content

Instantly share code, notes, and snippets.

@padde
padde / load_path_symlink.rb
Last active August 29, 2015 13:56
Adding lib directory to load path, even when called as a symlink
@padde
padde / inject_jquery.js
Last active August 29, 2015 13:56
Inject jQuery Bookmarklet
(function(){
var s = document.createElement('script');
s.setAttribute('src', 'https://code.jquery.com/jquery-latest.min.js');
if (typeof jQuery == 'undefined') {
document.getElementsByTagName('head')[0].appendChild(s);
}
})();
@padde
padde / 5F9D1786.asc.txt
Last active August 29, 2015 14:00
My PGP Public Key (7B8E 3327 8E52 E3E1 8392 92AE CCBB 382F 5F9D 1786)
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - https://gpgtools.org
mQINBFKjG38BEAC7ahP+UblWBW4MqOwjcFy2KdOS+dBkf77KNUCL4K+uFrmr0g8y
ux1eiTBvNVQ93p4DQIZJulfAS8AlSBHknVcA7RWLEvPt37g6yA2ppWW26ybEM4B/
ixXYMSNVGWKVJP6ce21GBGX/DtNWcjB7B3VB0y3qN1J+hoDOtd9ODoL2Hcl5tlMJ
G3hGK4IbPGIWTIN2YzV/ABondVIvcpn2GkKjcpFivuDubimb75QiwW9C3vF4NMjE
73lUm7ongQkZaBrevgGUXIt/LnEI/Dd7NPWrYDYE4HWa3hlfIHUiDNhr9dnsGT2d
6cuZY3LqRFBx707KQiW9Hv35R1rL5bkHsl8LiS7W/7TZdgNkyKZfBvcQmYSlW8D+
require 'continuation'
$__labels__ = {}
def label(label)
callcc {|cc| $__labels__[label] = cc }
end
def goto(label)
$__labels__[label].call
@padde
padde / gist:a2a789e504cdbfc739c1
Created June 20, 2014 12:54
Gitio Shell Alias
function gitio { curl -fsi git.io -F "url=$1" | grep 'Location' | sed 's/.*: //' | tee >(pbcopy) }
@padde
padde / portcheck.sh
Created July 2, 2014 22:42
Is port in use?
netstat -anp tcp | awk '$6 ~ "LISTEN" && $4 ~ "22$"'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def inspect(s):
if s is None:
return '"None"'
return '"' + str(s) + '"'
@padde
padde / array_to_proc.rb
Last active August 29, 2015 14:04
Pass arguments to Ruby shortcut procs
class Array
def to_proc
->(obj) { obj.public_send *self }
end
end
input = <<EOS
foo,bar,baz
hello,world
1,2,3
@padde
padde / open3.rb
Last active August 29, 2015 14:05
require 'open3'
command = 'sh'
Open3.popen2e(command) do |stdin, stdout_and_stderr, wait_thread|
Thread.new do
stdout_and_stderr.each {|l| puts l }
end
stdin.puts 'ls'
@padde
padde / brainfuck.ex
Created November 12, 2014 07:47
Brainfuck interpreter in Elixir
# Inspired by these blog posts:
# http://dev.mikamai.com/post/100075543414/elixir-as-a-parsing-tool-writing-a-brainfuck
# http://dev.mikamai.com/post/102283561929/elixir-as-a-parsing-tool-writing-a-brainfuck
defmodule Brainfuck do
@op_decv "-"
@op_incv "+"
@op_decp "<"
@op_incp ">"
@op_putc "."