Skip to content

Instantly share code, notes, and snippets.

@rday
rday / gist:4742553
Last active December 12, 2015 08:18
#
# Skeleton code, don't use this because it isn't going to work for you
"""
This is heavily taken from the MovingAverage
"""
import numpy
import talib
from numbers import Number
@rday
rday / gist:3712141
Created September 13, 2012 05:45
Json decode
package main
import "fmt"
import "encoding/json"
import "net/http"
import "bytes"
type Test struct{
Name string
Token string
@rday
rday / gist:3711685
Created September 13, 2012 03:36
Install Golang
# Setup your home directory to handle a go installation
mkdir ~/go
cd ~/
# Grab and untar the binary the binary
# If you have a 64bit system, use http://go.googlecode.com/files/go1.0.2.linux-amd64.tar.gz
wget http://go.googlecode.com/files/go1.0.2.linux-386.tar.gz
tar -xzf go1.0.2.linux-386.tar.gz
# Setup your environment to handle the root Go install
@rday
rday / gist:3504712
Created August 28, 2012 21:59
ConnectionPool Implementation
/**
This function creates a connection to the database. It shouldn't have to know anything
about the pool, It will be called N times where N is the size of the requested pool.
*/
func initCirrusConnections() (interface{}, error) {
dbserver, _ := configFile.GetString("default", "dbserver")
dbuser, _ := configFile.GetString("default", "dbuser")
dbpass, _ := configFile.GetString("default", "dbpass")
db := autorc.New("tcp", "", dbserver, dbuser, dbpass)
@rday
rday / gist:3504674
Created August 28, 2012 21:52
Abstract wrapper to allow connection pools
type InitFunction func() (interface{}, error)
type ConnectionPoolWrapper struct {
size int
conn chan interface{}
}
/**
Call the init function size times. If the init function fails during any call, then
the creation of the pool is considered a failure.
@rday
rday / gist:2644245
Created May 9, 2012 12:43
Quick IP addresses functions
import socket
import struct
def quadtolong(ip):
return struct.unpack('!L',socket.inet_aton(ip))[0]
def longtoquad(long):
return socket.inet_ntoa(struct.pack('!L', long))
def inc_ip(ip):