Skip to content

Instantly share code, notes, and snippets.

View emil-palm's full-sized avatar

Emil Palm emil-palm

  • Netnod Sverige AB
  • Stockholm, Sweden
View GitHub Profile
func setupAndRunViper(path, format string, viperCh) {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGHUP)
cnt := 0
for {
v := viper.New()
v.SetConfigFile(path)
v.SetConfigType(format)
var err error
from ujson import dumps
import pprint
class Test:
def __init__(self):
self.data = "foobar"
self._data = "barfoo"
class Test2(Test):
def toDict(self):
@emil-palm
emil-palm / gist:3368661
Created August 16, 2012 09:12
Setup git completion and a good PS1 var.
URLS="https://raw.github.com/git/git/master/contrib/completion/git-completion.bash https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh"
DONE=0
which "wget" >> /dev/null
if [ $? -eq 0 ]; then
for url in $URLS; do
OUT=$(echo $url | cut -f9 -s -d/)
wget $url -q -O ~/.$OUT
done
DONE=1
fi
@emil-palm
emil-palm / Join model assoc
Created April 15, 2012 12:58
Join model assoc
Class match:
has_many :match_maps
has_many :maps, :through => :match_maps, :conditions => {'match_maps.veto' => false}, :source => :map, :class_name => "Map"
has_many :vetos, :through => :match_maps, :conditions => { 'match_maps.veto' => true}, :source => :map, :class_name => "Map"
m = Match.find(1)
m.vetos << Map.find(1)
m.map << Map.find(2)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0 0 0 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0 0 0 1</string>
"""
Script to convert a Xcode3 Color theme into a Xcode4 one.
Example:
bash# python xcode3_theme_to_xcode4.py Twilight.xcolortheme
It will write a new file: Twilight.dvtcolortheme into the same folder as the script is residing in.
"""
import plistlib,sys
""" Define boilerplate of the color theme """
defaultConfig = {
function get_latest_html()
{
URL=$1
PATTERN=$2
TYPE=$3
LATEST=`curl -s ${URL} | egrep -o '<a href="([^\"]+)"' | awk -F\" '{print $2 }' | egrep ${PATTERN} | egrep ${TYPE} | egrep -v '(diff|sig)' | sort -nr | head -n1`
curl -s "${URL}/${LATEST}"
}
function get_latest_text()