Skip to content

Instantly share code, notes, and snippets.

View rhenning's full-sized avatar
👻

Richard Henning rhenning

👻
View GitHub Profile
@rhenning
rhenning / rhenning.zsh-theme
Created October 5, 2012 19:31
My zsh theme
# Hack of robbyrussell's theme, with RVM & Git indicators, but no host indicator
# Example:
# ✻ currentdir rvm:rubyversion@gemset git:branchname ✗
# Get the current ruby version in use with RVM:
if [ -e ~/.rvm/bin/rvm-prompt ]; then
RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:%{$fg[cyan]%}\$(~/.rvm/bin/rvm-prompt s i v g)%{$fg_bold[blue]%}%{$reset_color%} "
else
if which rbenv &> /dev/null; then
RUBY_PROMPT_="%{$fg_bold[blue]%}rbenv:%{$fg[cyan]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg_bold[blue]%}%{$reset_color%} "
@rhenning
rhenning / id_rsa_neat.pub
Created November 3, 2012 19:37
Rich's neat ssh public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCb1Rl3cfJNrppD1JH+ItXN5Hq/IBv6SNTEk1k1Gd8/j4nm05wPtpMDxnwYgt+g8VgVvwRc9v4Ff9I7O+jTU8OOJEGR0wMqb9URhaSbJhQ+hpElg7iWGPudxDGUR9ivyMEII7IlJCFPK2BqxRxdGoZ2IMgSfmntrRo9fTreO7g6maKV1DRgZtO8eSdPc6fPybuVyPMSt3VwPJIkHFXO7dezRrvFheei8MYdscsJxlXBgdGYYbfk2KBR2eCJzmYxLXXnirIriKXtAy4YYNOM/YBxfIwkdcq1RAgo5IdcN32TEoMxbt2+ykYnJBzECJn6A4of1eh27YAklHQzNl0KnwRf rhenning@neat.com
@rhenning
rhenning / gist:6023759
Last active December 19, 2015 21:58
ST2 User Preferences
{
"theme": "Soda Dark.sublime-theme",
"font_size": 11.0,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"tab_completion": true,
"detect_indentation": false,
"ignored_packages": [ "Vintage" ],
"sublimelinter_executable_map": { "ruby": "/Users/rhenning/.rvm/bin/rvm-auto-ruby" },
"sublimelinter_syntax_map": { "ruby": "/Users/rhenning/.rvm/bin/rvm-auto-ruby" }
@rhenning
rhenning / gist:7771812
Created December 3, 2013 16:03
Berkshelf thinks nonexistent cookbooks are frozen
rhenning@apprhenning:~/git/Provisioning/chef/cookbooks/neat-mongodb$ bundle exec berks upload --halt-on-frozen
Using neat-mongodb (0.1.0) from metadata
Using mongodb (0.13.7)
Using build-essential (1.4.2)
Using chef-sugar (1.0.1)
Using ebs (0.4.5)
Using xfsprogs (0.0.1)
Using aws (1.8.5)
Using neat_libraries (0.3.3)
Using chef-solo-search (0.5.1)
@rhenning
rhenning / speedfeed_sunspot.rb
Last active December 31, 2015 08:49
Synchronous Mongoid to Sunspot indexer
BATCH_LIMIT = 500
processed_event_count = 0
logger = Logger.new(STDOUT)
total_event_count = SearchIndexEvent.count
## had to get a little closer to the DB here due to a bug in Mongoid2
## that manifests when disabling cursor timeouts
SearchIndexEvent.collection.driver.find({}, :timeout => false) do |cursor|
@rhenning
rhenning / heapwatcher.rb
Created January 6, 2014 19:14
Watch JVM heap utilization
#!/usr/bin/env ruby
## run like: tail --lines=0 --follow=name /var/log/tomcat6/gc.log | this_ruby_script
ARGF.each do |line|
if match = /secs\]\s\d+K-\>(\d+)K\((\d+)K\)/.match(line)
heap_cur = match[1]
heap_lim = match[2]
heap_pct = heap_cur.to_f / heap_lim.to_f * 100.0
puts "#{heap_cur} / #{heap_lim} KiB : #{heap_pct}%"
@rhenning
rhenning / opsworks_blue_green_deploy_test_long_version
Created February 13, 2014 01:11
AWS OpsWorks full-stack blue/green deploy test
$ aws opsworks describe-stacks
{
"Stacks": [
{
"ServiceRoleArn": "arn:aws:iam::047170177871:role/aws-opsworks-service-role",
"StackId": "575e1389-1df3-427d-99d3-d60f89a41442",
"DefaultRootDeviceType": "ebs",
"Name": "rhenning_test",
"ConfigurationManager": {
"Version": "11.4",
@rhenning
rhenning / x509_cert_scan.rb
Last active August 29, 2015 13:59
Script to read information from remote X509 certificates
#!/usr/bin/env ruby
require 'openssl'
require 'socket'
require 'timeout'
DEFAULT_PORT=443
CONNECT_TIMEOUT=5
targets = ARGV.empty? ? ARGF : ARGV
filetype plugin on
filetype indent on
syntax enable
colorscheme desert
set background=dark
set expandtab
set smarttab
set shiftwidth=2
set tabstop=2
@rhenning
rhenning / entity_users.js
Last active August 29, 2015 14:07
Mongo aggregations and date to ObjectId
// run like: nohup mongo --quiet neat_prod > entity_users.js
days_ago = 120
date_after = new Date(new Date().setDate(new Date().getDate() - days_ago))
secs_after = Math.floor(date_after.getTime() / 1000)
oid_after = ObjectId(secs_after.toString(16) + "0000000000000000")
rs.slaveOk()
c = db.entities.find(