start new:
tmux
start new with session name:
tmux new -s myname
| /* | |
| * @in_params | |
| * center_hash - GeoHash identifier to find adjacent cells for | |
| * | |
| * @out_params (column description) | |
| * hash - GeoHash identifier for this adjacent cell | |
| * centroid - Centroid geometry (POINT) for this adjacent cell | |
| * bound - Cell bounds geometry (POLYGON) for this adjacent cell | |
| * | |
| * The function returns a SETOF RECORD containing the 8 direct |
| #!/usr/bin/env python | |
| """ | |
| Recipe for creating and updating security groups programmatically. | |
| """ | |
| import collections | |
| import boto |
| from django.core.mail import send_mail | |
| import os | |
| def sendMyAppEmail(toList, template, toType=None, subject="", templateDict={}): | |
| # Load the image you want to send at bytes | |
| img_data = open(os.path.join(settings.MEDIA_ROOT, 'bumblebee.jpeg'), 'rb').read() | |
| # Create a "related" message container that will hold the HTML |
| from hashlib import md5 | |
| from cPickle import dumps | |
| def make_hashes(data): | |
| ret = [md5(dumps(data)).hexdigest()] | |
| ret.extend([ | |
| md5(dumps(v)).hexdigest() for v in data.values() | |
| ]) |
| CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP(TIMESTAMP WITHOUT TIME ZONE) | |
| RETURNS BIGINT | |
| LANGUAGE SQL | |
| IMMUTABLE STRICT | |
| AS 'SELECT EXTRACT(EPOCH FROM $1)::bigint;'; | |
| CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP(TIMESTAMP WITH TIME ZONE) | |
| RETURNS BIGINT | |
| LANGUAGE SQL | |
| IMMUTABLE STRICT |
| # admin.py: admin action definition | |
| def make_copy(self, request, queryset): | |
| form = None | |
| if 'apply' in request.POST: | |
| form = CopyPageForm(request.POST) | |
| if form.is_valid(): | |
| issue = form.cleaned_data['issue'] |
| # models.py: overwritten model save method | |
| def save(self, *args, **kwargs): | |
| if self.cover: | |
| img_string = StringIO() | |
| pil_image = Image.open(self.cover.file) | |
| if pil_image: | |
| res_image = pil_image.resize((1034, 1400)) | |
| res_image.save(img_string, pil_image.format) | |
| # original image replaced by thumbnail | |
| self.cover.file = InMemoryUploadedFile( |
| '''switch implementation''' | |
| def a(what): | |
| print what | |
| def switch(what): | |
| try: | |
| {'1' : lambda : a('one'), | |
| '2' : lambda : a('two') | |
| }[what]() |
| import codecs | |
| infile = codecs.open("file", "r", "utf-8") | |
| line = infile.readline() | |
| while line: | |
| print line |