Skip to content

Instantly share code, notes, and snippets.

View aleszoulek's full-sized avatar

Ales Zoulek aleszoulek

  • Prague, Czech republic
View GitHub Profile
@aleszoulek
aleszoulek / example.py
Created March 1, 2017 20:55
lazy singleton example
print "Import time starts"
from lazy_object_proxy import Proxy
class Agent1(object):
def __init__(self):
print "Agent 1 called!"
def do_stuff(self):
print "Agent 1 doing stuff"
@aleszoulek
aleszoulek / shell
Created May 6, 2015 08:45
rebase is a lie
{repos } git init
Initialized empty Git repository in /home/ales/repos/.git/
{master repos } git ci -am 'initial' --allow-empty
[master (root-commit) 1096524] initial
# feature one commits
{master repos } git co -b feature-1
Switched to a new branch 'feature-1'
{feature-1 repos } touch 1
{feature-1 repos } git add 1
'http://www.idnes.cz/?a=://'
> /:\/\//.test('http://www.idnes.cz/?a=://')
true
> /:\/\//.test('www.idnes.cz/?a=://')
true
> /:\/\//.test('/?a=://')
true
@aleszoulek
aleszoulek / gist:8306058
Created January 7, 2014 20:11
Fabric: output
# fab -f /tmp/fab/bar.py host_type
[localhost] local: echo bar
bar
[localhost] local: uname -s
Linux
Done.
# fab -f /tmp/fab/bar.py host_type | cat
! Common
#define S_yellow #b58900
#define S_orange #cb4b16
#define S_red #dc322f
#define S_magenta #d33682
#define S_violet #6c71c4
#define S_blue #268bd2
#define S_cyan #2aa198
#define S_green #859900
{% set source = 'default' %}
{% if grains['a'] == foo %}
{% set source = 'foo' %}
{% endif %}
/a/b/c.conf:
file.managed:
- source: salt://{{ source }}
@aleszoulek
aleszoulek / gist:2038006
Created March 14, 2012 17:18
middleware order
MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'staticversions.middleware.DetectGzipSupportMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'scout.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'raven.contrib.django.middleware.SentryResponseErrorIdMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
@aleszoulek
aleszoulek / t.sh
Created May 5, 2011 21:25
tmux conf
#!/bin/bash
SESSION=main
tmux="tmux -2"
# if the session is already running, just attach to it.
$tmux has-session -t $SESSION
if [ $? -eq 0 ]; then
echo "Session $SESSION already exists. Attaching."
sleep 1
@aleszoulek
aleszoulek / gist:842170
Created February 24, 2011 13:49
list private repos that belongs to the organisation (python3)
#!/usr/bin/env python
import urllib.request
import json
ORGANISATION = ''
LOGIN = ''
TOKEN = ''
URL = 'http://github.com/api/v2/json/repos/show/%s?login=%s&token=%s' % (ORGANISATION, LOGIN, TOKEN)
{
'sources':
[
{
'name': 'bb1',
'url': 'http:///..../json',
'protocol': 'json',
},
{
'name': 'bb2',