Skip to content

Instantly share code, notes, and snippets.

View wolfeidau's full-sized avatar
🐺
Building data science projects

Mark Wolfe wolfeidau

🐺
Building data science projects
View GitHub Profile
#!/usr/bin/env bash
apt-get -y update
apt-get -y upgrade
apt-get -y install git build-essential autoconf zlib1g-dev libssl-dev \
libreadline-dev libyaml-dev libcurl4-openssl-dev curl python-software-properties \
ruby1.9.1 ruby1.9.1-dev rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1
gem install chef ruby-shadow --no-ri --no-rdoc
@wolfeidau
wolfeidau / gist:3475474
Created August 26, 2012 07:03
Some really bad javascript.
for(var header in request.headers) {
if (header !== 'Content-Md5'){ // need to omit a few entries more than this one..
mac.update(request.headers[header].toLowerCase());
}
}
@wolfeidau
wolfeidau / gist:3487288
Created August 27, 2012 10:30
Some testing via httperf
$ httperf --hog --server=165.225.144.167 --wsess=10,5,2 --rate=1 --timeout=5
httperf --hog --timeout=5 --client=0/1 --server=165.225.144.167 --port=80 --uri=/ --rate=1 --send-buffer=4096 --recv-buffer=16384 --wsess=10,5,2.000
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 1
Total: connections 10 requests 50 replies 50 test-duration 18.373 s
Connection rate: 0.5 conn/s (1837.3 ms/conn, <=10 concurrent connections)
Connection time [ms]: min 9343.0 avg 9463.5 max 9586.1 median 9445.5 stddev 91.0
#!/bin/bash
#
# Bootstrap script for installing chef on smartos in a ZONE.
#
# NOTE: This is a nondeterministic method of installing chef and should be used for dev / test systems.
#
if [ ! -f /opt/local/bin/chef-solo ]; then
if [ -e /tmp/rubygems ]; then
rm -rf /tmp/rubygems
@wolfeidau
wolfeidau / gist:3734850
Created September 16, 2012 23:46
Twitter bootstrap fragment
<div class="container-fluid">
<div class="row-fluid">
<div class="span2" style="background: #4682b4;">
<!--Sidebar content-->
</div>
<div class="span10" style="background: #4682b4;">
<!--Body content-->
</div>
</div>
</div>
@wolfeidau
wolfeidau / gist:3779953
Created September 25, 2012 04:15
bower go boom
bower info jquery
events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: Git status: 128
at Package.cache (/usr/local/lib/node_modules/bower/lib/core/package.js:292:50)
at ChildProcess.EventEmitter.emit (events.js:91:17)
at maybeClose (child_process.js:634:16)
at Socket.ChildProcess.spawn.stdin (child_process.js:806:11)
@wolfeidau
wolfeidau / arg.d
Created October 16, 2012 12:06
DTrace to snoop out processes executed on an OSX system and display their command line
#!/usr/sbin/dtrace -C -s
#pragma D option quiet
proc::posix_spawn:exec-success,proc::__mac_execve:exec-success
{
this->isx64=(curproc->p_flag & P_LP64)!=0;
#define SELECT_64_86(x64, x86) (this->isx64 ? (x64) : (x86))
#define GET_POINTER(base, offset) (user_addr_t)SELECT_64_86(*(uint64_t *)((base)+sizeof(uint64_t)*(offset)), *(uint32_t *)((base)+sizeof(uint32_t)*(offset)))
this->ptrsize=SELECT_64_86(sizeof(uint64_t),sizeof(uint32_t));
@wolfeidau
wolfeidau / gist:3901651
Created October 16, 2012 20:07
Riak Ruby Client Observations

Background

I have spent a few hours setting up, running and then digging into the riak ruby client, this was based on message posted by @seancribbs inviting people to assist in debugging some issues he was having with "intermittent failure around the generated node not starting".

Review

On investigation of the issues, and a read over the code in general I came across a couple of things I would fix first.

In both of the following instances I would rewrite the process management code which executes riak and riak-admin tools. Currently it is not consistent in it's checking response codes or error output, this in my view is bad.

@wolfeidau
wolfeidau / execsnoop.d
Created October 17, 2012 07:03
Slightly modified version of the super handy execsnoop.d which works on OSX
#!/usr/sbin/dtrace -s
/*
** execsnoop.d - snoop process execution as it occurs.
** Written in DTrace (Solaris 10 build 51).
**
** NOTE: This version is deprecated. See "execsnoop",
** http://www.brendangregg.com/dtrace.html
**
** 27-Mar-2004, ver 0.60
**
@wolfeidau
wolfeidau / gist:3920449
Created October 19, 2012 20:17
Output of Mixlib::ShellOut showing normal ping vs riak ping stdout, stderr differences

In the following output you can see execution of the OSX ping command, the pingc.run_command is where we can see the output of a failed ping.

1.9.3p194 :009 > pingc = Mixlib::ShellOut.new("ping", "beer.invalid")
 => <Mixlib::ShellOut#70097041980820: command: '["ping", "beer.invalid"]' process_status: nil stdout: '' stderr: '' child_pid: nil environment: {"LC_ALL"=>"C"} timeout: 600 user:  group:  working_dir:  > 
1.9.3p194 :010 > pingc.run_command
 => <Mixlib::ShellOut#70097041980820: command: '["ping", "beer.invalid"]' 
process_status: #<Process::Status: pid 87108 exit 68> 
stdout: '' 
stderr: 'ping: cannot resolve beer.invalid: Unknown host' 

child_pid: 87108 environment: {"LC_ALL"=>"C"} timeout: 600 user: group: working_dir: >