Skip to content

Instantly share code, notes, and snippets.

View vortec's full-sized avatar

Fabian Kochem vortec

View GitHub Profile
ALLOWED = {
unichr(9), # 0x09 - CHARACTER TABULATION (\t)
unichr(10), # 0x0A - LINE FEED (\n)
unichr(13) # 0x0D - CARRIAGE RETURN (\r)
}
DISALLOWED = set(map(unichr, range(0,32) + range(127,160))) | {
unichr(160) # 0x0A - NO-BREAK SPACE
}
test:
virtualenv.create:
- path: /opt/cate2/
- pip: True
- runas: cate
foobar:
archive.tar:
- sources: http://download.redis.io/releases/redis-2.8.3.tar.gz
- dest: /opt/redis-2.8
############ OUTPUT ############
State: - archive
Name: REPLACEME
Function: tar
root@(none):~/debian-installer-20130613+deb7u1/build# fakeroot make rebuild_netboot
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = (unset)
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
>>> foo = 12
>>> def func():
... print foo
...
>>> func()
12
>>> x = {1, 2, 3}
>>> y = [3, 4, 5]
>>> x.intersection(y)
{3}
>>> x & y
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for &: 'set' and 'list'
>>>
[fkochem@FK] ~/temp $ mkdir blubb †: 0
[fkochem@FK] ~/temp $ cd blubb †: 0
[fkochem@FK] ~/temp/blubb $ git init †: 0
Initialized empty Git repository in /Users/fkochem/temp/blubb/.git/
[fkochem@FK] ~/temp/blubb (git)-[master]$ touch meh †: 0
[fkochem@FK] ~/temp/blubb (git)-[master]$ cat > meh †: 0
this
is
my
awesome
#!/bin/bash
oldrev=$(git rev-parse $1)
newrev=$(git rev-parse $2)
refname="$3"
case "$refname","$rev_type" in
refs/tags/*,tag)
# annotated tag
refname_type="annotated tag"
function="atag"
short_refname=${refname##refs/tags/}
import re
f1 = 'my movie title #12'
f2 = 'my other movie title'
my_regex = re.compile(r'^(?P<movie>.*)( #(?P<version>\d+))$')
result = re.match(my_regex, f1)
if result:
print result.groupdict()
@vortec
vortec / gist:5843378
Created June 23, 2013 01:35
Late night implementation of Tornado + Redis PubSub + Websockets. It's late, the code is messy, but it should demonstrate how the general construct works. Feel free to try it on your own after studying it.
import json
import os
import tornado.httpserver
import tornado.web
import tornado.websocket
import tornado.ioloop
import tornado.gen
import tornadoredis