Skip to content

Instantly share code, notes, and snippets.

View brendon9x's full-sized avatar

Brendon McLean brendon9x

View GitHub Profile
{
name: "awareness",
label: "Brand Awareness",
type: "binary", # question/measure type
dimensions: ["respondent", "brand"],
values: {
respondent: [1,1,3,4,...],
brand: [1,2,2,2,...],
value: [1,1,1,0,...]
}
@brendon9x
brendon9x / bundle.env
Created February 21, 2017 08:39
Bundle update error
## Environment
```
Bundler 1.14.3
Rubygems 2.6.10
Ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin15]
GEM_HOME /Users/brendon/.rvm/gems/ruby-2.3.3@insight-app
GEM_PATH /Users/brendon/.rvm/gems/ruby-2.3.3@insight-app:/Users/brendon/.rvm/gems/ruby-2.3.3@global
RVM 1.29.0 (master)
Git 2.11.0
@brendon9x
brendon9x / commands.gdb
Created August 11, 2015 08:05
Ruby stack dump
define redirect_stdout
call rb_eval_string("$_old_stdout, $stdout = $stdout, File.open('/tmp/ruby-debug.' + Process.pid.to_s, 'a'); $stdout.sync = true")
end
define ruby_eval
call(rb_p(rb_eval_string_protect($arg0,(int*)0)))
end
redirect_stdout
@brendon9x
brendon9x / pretty_routes.rake
Created February 24, 2015 15:17
Pretty route printer for Rails
desc 'Pretty version on rails rake routes.'
black = "\033[1;30m"
red = "\033[1;31m"
yellow = "\033[1;33m"
blue = "\033[1;34m"
magenta = "\033[1;35m"
cyan = "\033[1;36m"
white = "\033[1;37m"
no_color = "\033[0m"
@brendon9x
brendon9x / adhoc.xml
Created October 16, 2014 15:14
Expected structure of additional info
<AdditionalInfo>
<Name>Ipsos_Test1012_South Africa_Beverages</Name>
<Uom>R</Uom>
<MarketValue>10000</MarketValue>
<BvcSourceType>BVC Self-Service</BvcSourceType>
</AdditionalInfo>
@brendon9x
brendon9x / cleanup.sh
Created April 2, 2014 07:45
OldStack running out of space on /
sudo -s
cd /tmp
find . -name '*.png' -delete
def sort_key(obj)
if obj.is_a?(Array)
obj.map { |o| sort_key o }
elsif obj.respond_to?(:is_a_number?) && obj.is_a_number?
obj.to_f
elsif obj.respond_to?(:downcase)
obj.downcase
else
obj
end
#!/usr/bin/perl
#fetch Gravatars
use strict;
use warnings;
use LWP::Simple;
use Digest::MD5 qw(md5_hex);
my $size = 90;
@brendon9x
brendon9x / list_rack_versions.rb
Last active December 10, 2015 23:38
For listing Rails versions in Apache
#!/usr/bin/ruby
files = Dir["reports*"]
files.each do |f|
dir = File.join(`cat #{f}|grep DocumentRoot`.lines.first.split(/\s+/).last.split(/\//)[0..-2])
rails_version = `cd #{dir}; rvm exec bundle list|grep ' rack'`.match(/\(([^)]+)\)/)[1]
deployed_version = `cd #{dir}; cat version`
deployed_branch = `cd #{dir}; cat config/environments/capistrano/#{f.to_s.gsub(/reports_/, '')}.rb|grep :branch`
puts "#{f}: #{rails_version}@#{deployed_version} - #{deployed_branch}"
end