This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import random | |
closeds = json.load(open('closed.json')) | |
opens = json.load(open('open.json')) | |
def today(pr): | |
return pr['created_at'].startswith('2014-02-15') | |
prs = [p for p in (opens+closeds) if today(p)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user www-data; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
# multi_accept on; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script is a wrapper around gunicorn | |
# It provides clean interface for starting stopping app server | |
PROJECT_NAME=photon | |
HOME_DIR=/home/photon | |
RELEASE_DIR=$HOME_DIR/releases/current | |
GUNICORN_BIN=$HOME_DIR/bin/gunicorn_django | |
GUNICORN_PID=$HOME_DIR/pids/gunicorn.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
def fib_gen(): | |
a, b = 1, 1 | |
while True: | |
yield a | |
a, b = b, a+b | |
def get_values(iterator, n): | |
l = [] | |
for i in range(n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
def fib_gen(): | |
a, b = 1, 1 | |
while True: | |
yield a | |
a, b = b, a+b | |
def get_values(iterator, n): | |
l = [] | |
for i in range(n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
""" | |
Dependency injection made simple | |
@requires('stores') | |
class Action(object): | |
self.stores = None | |
@provides('stores') | |
class InMemoryStores(Stores): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cascade) % ./manage.py syncdb | |
Creating tables ... | |
Creating table ticket_a | |
Creating table ticket_b | |
Creating table ticket_c | |
Installing custom SQL ... | |
Installing indexes ... | |
No fixtures found. | |
(cascade) % ./manage.py shell | |
Python 2.7.2 (default, Jan 17 2012, 23:42:54) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render_dict(pattern, data): | |
"""Render Django model to dict (helps in rendering JSON)""" | |
out = {} | |
for item in pattern: | |
if isinstance(item, basestring): | |
attr = manager_getattr(data, item) | |
out[item] = attr | |
elif isinstance(item, dict): | |
for subitem, subpattern in item.items(): | |
attr = manager_getattr(data, subitem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gchat | |
import "log" | |
import "net" | |
import "bufio" | |
import "fmt" | |
func Serve() { | |
fmt.Println("Start server on port 2000") | |
l, err := net.Listen("tcp", ":2000") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TASK: [debug msg="/home/$user/13-02-17--15-23-58"] ********************* | |
ok: [192.168.60.2] | |
TASK: [pause seconds=5] ********************* | |
(^C-c = continue early, ^C-a = abort) | |
[192.168.60.2] | |
Pausing for 5 seconds | |
ok: [192.168.60.2] | |
TASK: [debug msg="/home/$user/13-02-17--15-24-04"] ********************* |
OlderNewer