Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"os"
"reflect"
"strconv"
"strings"
clowder "github.com/redhatinsights/app-common-go/pkg/api/v1"
@psav
psav / HAProxy setup steps
Last active September 28, 2015 15:00 — forked from blomquisg/HAProxy setup steps
Setting up HAProxy for OpenStack SSL
1. Install HA Proxy package
#> yum install haproxy
2. Generate the self-signed cert
#> mkdir -p /etc/pki/haproxy
#> umask 077 && openssl genrsa -out /etc/pki/haproxy/haproxy.key 1024
#> umask 022 && openssl req -key /etc/pki/haproxy/haproxy.key \
-out /etc/pki/haproxy/haproxy.crt \
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
;(package-refresh-contents)
\score {
\new DrumStaff
<<
\set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)
\context DrumVoice = "1" { s1 }
\context DrumVoice = "2" { s2 }
\drummode {
<<
{
toml8 <toml sn>8 toml16 sn16 toml8 <toml sn>8 toml16 sn16~ sn16 toml16 sn8| % use bar checks
#(define mydrums '(
(bassdrum default #f -3)
(snare default #f 1)
(hihat cross #f 5)
(halfopenhihat cross "halfopen" 5)
(pedalhihat xcircle "stopped" 2)
(lowtom diamond #f 3)
(crashcymbal cross #f 6)))
up = \drummode { hh8 hh hhho hhho hhp4 hhp }
class Appliance(object):
def __init__(self, var):
print "inited"
self.var = var
def __enter__(self):
print "entering"
print "the var is {}".format(self.var)
return self
@psav
psav / ip_scraper.py
Created April 2, 2014 16:29
IP Scraper, pipable ;)
import re
import sys
if __name__ == "__main__":
data = sys.stdin.read()
ips = set([b[0] for b in re.findall('((\d{1,3}\.){3}\d{1,3})', data)])
for ip in sorted(ips):
print ip
@psav
psav / gist:8600888
Last active January 4, 2016 09:19
Defer
>>> def defer(func, *args):
... return partial(partial, func)(*args)
...
>>> defer(max, [1,2,3])
<functools.partial object at 0xe411b0>
>>> p = defer(max, [1,2,3])
>>> p()
3
>>>
>>> b = partial(max, [1,2,3])
@pytest.fixture(params=['a', 'b'])
def do_something(request):
print request.param
@pytest.usefixtures(do_something, params=['c'])
def do_something_with_something_else():
'''Like to pass a custom setof params to the fixture'''