Skip to content

Instantly share code, notes, and snippets.

@asenchi
asenchi / cassandra-on-ec2.sh
Created January 18, 2012 15:00 — forked from andreisavu/cassandra-on-ec2.sh
Deploying Cassandra on EC2 with Whirr
# Cassandra on EC2 using Apache Whirr trunk (18 January 2012)
# Clone the repo from the Apache servers
git clone git://git.apache.org/whirr.git
cd whirr
# build binary artefacts on your machine
mvn clean install
@asenchi
asenchi / pipe.go
Created January 17, 2012 21:13 — forked from dustin/pipe.go
generic tcp proxy
package main
import (
"flag"
"io"
"log"
"net"
"runtime"
)
@asenchi
asenchi / main.go
Created November 18, 2011 18:39
Go solution to the Instagram Engineering Challenge (http://goo.gl/B92t0).
// A solution to the Instagram Engineering Challenge (http://goo.gl/B92t0)
package main
import (
"fmt"
"image"
"image/draw"
"image/jpeg"
"image/png"
"io"
@asenchi
asenchi / pyrocfile.py
Created November 14, 2011 19:25 — forked from testac/pyrocfile.py
pyrocfile - 100 line Procfile manager in Python
# Pyrocfile - Simple Python impementation of Procfile manager
# Written by Chris Testa (http://testa.co/) in 2011
# Released in the Public Domain
import argparse, logging, os.path, random, re, select, signal, subprocess
def _new_logger(name, color=None):
logger = logging.getLogger(name)
hdlr = logging.StreamHandler()
color, end_color = '\033[9%dm' % (color or random.randint(1, 6)), '\033[0m'
from os import listdir, system
ip = raw_input("Destination server IP: ")
for dir in listdir('/var/cpanel/users'):
system('/scripts/pkgacct --skiphomedir --nocompress %s /home cpmove' % dir)
system('scp /home/cpmove-*.tar root@%s:/home/' % ip)
system('rsync -avHle ssh /home/%s/ root@%s:/home/%s/ --progress' % (dir, ip, dir))
@asenchi
asenchi / nginx.conf
Created September 20, 2011 06:18 — forked from huacnlee/nginx.conf
Nginx http proxy cache to mirror of Rubygems.org
# 在本地服务器建立 rubygems.org 的镜像缓存,以提高 gem 的安装速度
# 此配置设置缓存过期为1天,也就是说,新上的 gem 无法马上安装
# 做这个起什么作用?
# rubygems 的很多资源文件是存放到 Amazon S3 上面的,由于 GFW 对某些 S3 服务器又连接重置或丢包,导致 gem 安装异常缓慢或有时候根本无法连接安装。
# 而通过这种跳板的方式可以很好的解决这个问题,当然前提是 Nginx反向代理 服务器需要在国外
proxy_cache_path /var/cache/rubygems levels=1:2 keys_zone=RUBYGEMS:10m
inactive=24h max_size=1g;
server {
listen 80;
@asenchi
asenchi / gist:1205314
Created September 9, 2011 01:59 — forked from avalanche123/gist:981817
GitHub Emoji
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@asenchi
asenchi / biggest_relations.txt
Created September 7, 2011 02:03 — forked from nesquena/basic.sql
PostgreSQL Common Utility Queries
# Finding the total size of your biggest tables
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 20;
@asenchi
asenchi / notes.md
Created September 6, 2011 13:55 — forked from ricardochimal/notes.md
Vim formula for Homebrew
 $ brew install python --framework
 $ mkdir ~/Library/Frameworks/
 $ cd ~/Library/Frameworks/
 $ ln -s /usr/local/Cellar/python/2.7.2/Frameworks/Python.framework .
 $ brew install -vd ./vim.rb
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(