Skip to content

Instantly share code, notes, and snippets.

@wbailey
wbailey / install-madlib-os-x-postgresql12
Last active April 29, 2020 01:34
Installing Apache MADLib on OS X using Postgresql
The documentation for madlib is out of date because brew no longer supports compiler flags from the command line.
Select the appropriate steps according to your current install on OS X
*PYTHON*
brew install python
export PYTHON=/usr/local/bin/python3
*Postgresql*
@wbailey
wbailey / .bash_profile
Last active May 26, 2022 03:13
Automatically add the current directory to the GOPATH when changing into it
# GOPATH helper
goPathFile="$HOME/.gopathsrc"
if [ -f "$goPathFile" ]; then
source "$goPathFile"
fi
set history=256
set autowrite
set autoread
set timeoutlen=250
set clipboard+=unnamed
set directory=~/.vim/swap
set hlsearch
set incsearch
@wbailey
wbailey / gist:7363555
Last active December 27, 2015 17:39
simple regex for jason
1.9.3-p392 :026 > s
=> "DB2:/XMETA/NODE0000/DB2LOG"
1.9.3-p392 :028 > /^([^\/]*\/[^\/]*\/).*$/.match(s)
=> #<MatchData "DB2:/XMETA/NODE0000/DB2LOG" 1:"DB2:/XMETA/">
1.9.3-p392 :030 > /^([^\/]*\/[^\/]*)\/.*$/.match(s)
=> #<MatchData "DB2:/XMETA/NODE0000/DB2LOG" 1:"DB2:/XMETA">
@wbailey
wbailey / pi.go
Created May 30, 2013 17:22
Statistical method for determine the value of Pi in Ruby and Go
package main
import (
"fmt"
"math"
"math/rand"
"time"
)
var pi, dev float64
@wbailey
wbailey / haproxyd.sh
Created December 22, 2011 06:24
Setting up haproxy as a daemon on your ubuntu server
#!/bin/bash
CONFIG=/etc/haproxy/haproxy.cfg
DAEMON=$(which haproxy)
function get_pid() {
PID=$(ps aux | grep haproxy | grep -v grep | awk '{print $2}')
}
function get_status() {
@wbailey
wbailey / monitor_search
Created October 13, 2011 16:07
Monitoring remote services using SSH
@wbailey
wbailey / solr_heartbeatd
Created August 2, 2011 18:34
A daemon to monitor and restart the solr server on our slave host
#!/bin/bash
url='http://www.sitetomonitor.com/provider_search?utf8=%E2%9C%93&search%5Bquery%5D=aba+therapist&search%5Blocation%5D=San+Francisco%2C+CA&commit=Search'
self=$(basename $0)
if [ -w "/var/run" ]; then
pidfile="/var/run/$self.pid"
else
pidfile="/tmp/$self.pid"
fi
@wbailey
wbailey / keypad.rb
Created April 1, 2011 08:29
converting some bad sql to correct sql with proper phone numbers
def keypad str
case str.downcase
when 'a'..'c' then '2'
when 'd'..'f' then '3'
when 'g'..'i' then '4'
when 'j'..'l' then '5'
when 'm'..'o' then '6'
when 'p'..'s' then '7'
when 'a'..'v' then '8'
when 'w'..'z' then '9'
require 'stringio'
def capture_stdout
$stdout = StringIO.new
$stdin = StringIO.new("y\n")
yield
$stdout.string.strip
ensure
$stdout = STDOUT
$stdin = STDIN