Skip to content

Instantly share code, notes, and snippets.

View jgyllen's full-sized avatar
👋

Jacob Gyllenstierna jgyllen

👋
View GitHub Profile
@jgyllen
jgyllen / gist:1e504a2757cee34f3db2
Created January 7, 2016 00:30
Kill list of processes
kill `ps aux | grep foo | grep -v grep | awk '{print $2}'`
@jgyllen
jgyllen / config.ru
Created October 10, 2012 02:45
Sharing Rails cookie session with a Sinatra app
use Rack::Config do |env|
env[ActionDispatch::Cookies::TOKEN_KEY] = 'abc123' # Secret token from Rails config
end
use ActionDispatch::Session::CookieStore, key: '_myapp_session' # Session key from session store options in Rails config
run MyApp
@jgyllen
jgyllen / gist:2410991
Created April 18, 2012 03:48
Disabling the character picker in Mac OS X Lion
$ defaults write -g ApplePressAndHoldEnabled -bool false
@jgyllen
jgyllen / gist:2312464
Created April 5, 2012 16:48
Create a secure random string in Ruby 1.9
SecureRandom.base64(6).gsub(/[$=+\/]/,65.+(rand(25)).chr)
@jgyllen
jgyllen / gist:1995443
Created March 7, 2012 19:36
Print SSH key fingerprint
$ ssh-keygen -lf ~/.ssh/id_rsa.pub
@jgyllen
jgyllen / gist:1386534
Created November 22, 2011 18:55
sed commands
# Find rows containing string 'foo' in file bar.txt
$ sed -n '/foo/p' < bar.txt
# Replace occurrences of 'foo' with 'bar' in baz.txt and backup original to baz.txt.bak
$ sed -i.bak -e 's%foo%bar%' baz.txt
@jgyllen
jgyllen / gist:1353155
Created November 9, 2011 21:38
Equivalent of using MongoDB's $size operator for embedded collections
# All activities with one comment or more
Activity.collection.find('$where' => "function() { if (this['activity_comments'] && this['activity_comments'].length > 0) return true; }")
@jgyllen
jgyllen / gist:1238037
Created September 23, 2011 18:04
Showing hidden files in TextMate project drawer
Go to Preferences > Advanced > Folder Preferences and set File Pattern to:
!(/\.(?!.)[^/]*|\.(tmproj|o|pyc)|/Icon\r|/svn-commit(\.[2-9])?\.tmp)$
@jgyllen
jgyllen / gist:840163
Created February 23, 2011 08:15
Extracting information from an SSL certificate using OpenSSL
# Using the -text option will give you the full breadth of information.
openssl x509 -text -in cert.pem
# Other options will provide more targeted sets of data.
# who issued the cert?
openssl x509 -noout -in cert.pem -issuer
# to whom was it issued?
@jgyllen
jgyllen / gist:839690
Created February 22, 2011 23:53
RabbitMQ+SSL with Ruby
# rabbitmq.config
[
{rabbit, [
{tcp_listeners,[{"127.0.0.1",5672}]},
{ssl_listeners, [{"127.0.0.1",5671}]},
{ssl_options, [{cacertfile,"/usr/local/etc/rabbitmq/ssl/testca/cacert.pem"},
{certfile,"/usr/local/etc/rabbitmq/ssl/server/cert.pem"},
{keyfile,"/usr/local/etc/rabbitmq/ssl/server/key.pem"},
{verify,verify_none},
{fail_if_no_peer_cert,false}]}