Skip to content

Instantly share code, notes, and snippets.

View wozozo's full-sized avatar
😇
Hello

wozozo

😇
Hello
  • Tokyo, Japan
  • 19:49 (UTC +09:00)
View GitHub Profile
@ukyo
ukyo / autoreference_dbref_patch.py
Created September 25, 2011 05:05
pymongo AutoReference DBRef patch
#coding: utf8
"""pymongoのAutoReferenceにパッチ当てるやつ
リスト内のDBRef全部にクエリを発行せずに{$in: [1,2,...,n]}する。
Example:
>>> from pymongo.son_manipulator import AutoReference, NamespaceInjector
>>> import autoreference_dbref_patch
"""
@leah
leah / json-response.py
Created October 5, 2011 19:08
JSONResponse classes
import re
import simplejson
from django.http import HttpResponse
from django.conf import settings
class JSONResponse(HttpResponse):
def __init__(self, request, data):
indent = 2 if settings.DEBUG else None
@aita
aita / gist:1300634
Created October 20, 2011 07:57
ListFormView
class ListFormMixin(MultipleObjectMixin, FormMixin):
'''フォームを持つListViewの実装のためのMixin
memo:
get_context_dataメソッドが重複する
'''
class BaseListFormView(ListFormMixin, View):
def get(self, request, *args, **kwargs):
@Seasons7
Seasons7 / app.js
Created October 30, 2011 13:27
Titanium Growl Animation
Titanium.UI.setBackgroundColor('#000');
var window = Ti.UI.createWindow({
title:'テスト',
backgroundColor:'#FFF'
});
var label = Ti.UI.createLabel({
bottom:0,
color:'#FFF',
@RobertSzkutak
RobertSzkutak / ircecho.py
Created October 30, 2011 21:15
Echo, a simple IRC bot written in Python 3
#!/usr/bin/env python3
# ircecho.py
# Copyright (C) 2011 : Robert L Szkutak II - http://robertszkutak.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
@juno
juno / gist:1497194
Created December 19, 2011 13:18
EC2 RunInstances API returns InsufficientInstanceCapacity
$ ec2-run-instances --region us-east-1 \
  --availability-zone us-east-1a \
  --group default \
  --key foo \
  --instance-type t1.micro \
  ami-XXXXXXXX

Server.InsufficientInstanceCapacity: We currently do not have sufficient t1.micro capacity in the Availability Zone you requested (us-east-1a). Our system will be working on provisioning additional capacity. You can currently get t1.micro capacity by not specifying an Availability Zone in your request or choosing us-east-1d, us-east-1b.

@podhmo
podhmo / gist:1504506
Created December 21, 2011 04:00
flatten
def flatten(xs):
for x in xs:
if hasattr(x, "__iter__"):
yield from flatten(x)
else:
yield x
function declitimg(img) {
var cv = document.createElement('canvas');
cv.width = img.width;
cv.height = img.height;
var ctx = cv.getContext('2d');
ctx.drawImage(img, 0, 0);
var imd = ctx.getImageData(0, 0, img.width, img.height);
var s = '';
for (var i = 0; i < imd.data.length && imd.data[i] !== 0;) {
var c1 = imd.data[i++];
@riywo
riywo / os_type
Created January 7, 2012 04:52
OSのタイプをなんとなく出力
#!/bin/sh
if [ $OSTYPE = "linux-gnu" ]; then
LSB_ID=`lsb_release -i | cut -f2 -d:`
LSB_VERSION=`lsb_release -r | cut -f2 -d:`
OS_VERSION=`echo $LSB_ID-$LSB_VERSION | sed -e "s/ //g"`
MACHINE_TYPE=`uname -m`
echo $OS_VERSION-$MACHINE_TYPE
else
echo `uname -rsm | sed -e "s/ /-/g"`
fi
@oyakata
oyakata / README.rst
Created February 16, 2012 07:17
pytestをちょっと試した

pytest

Installation and execution

$ pip install pytest

$ py.test test_foo.py