Skip to content

Instantly share code, notes, and snippets.

View tsnow's full-sized avatar

Tim Snowhite tsnow

  • Palantir
  • Washington, DC
View GitHub Profile
@tsnow
tsnow / junos_wrrrrryyyyyyyy.sh
Created September 26, 2012 21:20
Fix Junos Pulse when it commits Seppuku on Mountain Lion
ps aux | grep Junos | awk '{print $2}' | xargs kill
sudo rm -r ~/Library/Application\ Support/Juniper\ Networks/*
@tsnow
tsnow / dynamic_undocumented_requires.rb
Created September 26, 2012 21:58
why soap4r-ruby1.9, why?
def web_client
return @web_client if @web_client
begin
require 'httpclient'
@web_client = HTTPClient
rescue LoadError
begin
require 'http-access2'
if HTTPAccess2::VERSION < "2.0"
raise LoadError.new("http-access/2.0 or later is required.")
@tsnow
tsnow / class_variables.rb
Created October 18, 2012 13:22
Wait. What?
1.9.3p286 :151 > module P
1.9.3p286 :152?> @@b = 1
1.9.3p286 :153?> end
=> 1
1.9.3p286 :154 > class A
1.9.3p286 :155?> include P
1.9.3p286 :156?> end
=> A
1.9.3p286 :157 > class B
1.9.3p286 :158?> include P
@tsnow
tsnow / parsable.rb
Created October 19, 2012 17:44
A Rack-like functionality for OptionParser
module Parsable
def self.included(mod)
class << mod
attr_accessor :child_parser
end
mod.child_parser = NullParsable.new
mod.class_eval do
def child_parser
self.class.child_parser
@tsnow
tsnow / sections.js
Created December 20, 2012 20:32 — forked from anonymous/sections.js
//js
function haversine(lat1,lon1,lat2,lon2){
var R = 6371; // km
var dLat = (lat2-lat1) / (360 / (2 * 3.1415926));
var dLon = (lon2-lon1) / (360 / (2 * 3.1415926));
var lat1 = (lat1 / (360 / (2 * 3.1415926)));
var lat2 = (lat2 / (360 / (2 * 3.1415926)));
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
@tsnow
tsnow / perf_tuning.rb
Created December 20, 2012 20:41
high perf tuning freebsd webservers - @jssjr
if node['platform'] == "freebsd"
# load the http accept filter into the kernel
freebsd_kernel_module "accf_http"
# increase max files
freebsd_sysctl "kern.maxfiles" do
value 131072
end
# increase the max pending socket limit
@tsnow
tsnow / _sort_env_json.rb
Last active December 10, 2015 00:19
sorting environments/*.json for chef
#! /usr/bin/env ruby
# ruby sort_env_json.rb environments/*.json
# ruby sort_env_json.rb environments/*.json --like environments/prod.json
require './json_file'
require 'optparse'
begin
$stderr.puts "please supply a list of environments/*.json paths you'd like to have sorted alphabetically"
exit(1)
@tsnow
tsnow / buildpims.sh
Last active December 11, 2015 02:29 — forked from anonymous/pkg_list
build_pims.sh and mount_nfs.sh are both on my ~/Desktop in the vm. README.txt and setup.sh are under ~/ and came with the image. Here for illustration.
if [ "" == "$1" ]; then echo "Usage: build_pims.sh [arm|x86]"; exit 1; fi
cd -P `dirname $0`/pims;
pwd;
scripts/reallyclean.sh &&
echo "gen" &&
scripts/"runqmake-$1" &&
echo "record number" &&
scripts/buildnumber &&
echo "make" && make -s
db/schema.rb merge=railsschema
@tsnow
tsnow / README.md
Last active May 17, 2021 14:39
Ridecharge Ruby Data Processing Programming Take-Home Assignment

Spend 5 literal minutes thinking:

  • How much time do you have to devote to this exercise?
  • How can you verify that your solution is correct?

Then:

  1. Fork this gist and clone it locally.

  2. Send [email protected] and [email protected] a link to your forked gist with "[gh_repo_stats]" in the subject. Provide an estimate of how long you'll be working on your solution in man-hours and an estimate of when you will be finished. Feel free to ask any questions about the assignment, as well.