Skip to content

Instantly share code, notes, and snippets.

View wozozo's full-sized avatar
😇
Hello

wozozo

😇
Hello
  • Tokyo, Japan
  • 22:25 (UTC +09:00)
View GitHub Profile
@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
@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.

@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.
#
@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',
@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):
@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
@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
"""
@gwik
gwik / geventmongo.py
Created August 31, 2011 18:17
PyMongo >=2.0 pool for gevent
# Copyright 2011 10gen
#
# Modified by Antonin Amand <[email protected]> to work with gevent.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@syoichi
syoichi / gyazocom_redirect_to_ima.user.js
Created June 19, 2011 00:36 — forked from youpy/gyazocom_redirect_to_ima.user.js
gyazo.comの画像にアクセスすると広告ページへリダイレクトするようになっていたので、cache.gyazo.comの画像にリダイレクトするように修正した。
// ==UserScript==
// @name Gyazo.com: Redirect to image
// @namespace http://buycheapviagraonlinenow.com/
// @include http://gyazo.com/*
// @include http://cache.gyazo.com/*
// @author youpy
// @compatibility Firefox 5.0(Scriptish 0.1.3), Chrome 12.0.742.122, Safari 5.0.5(NinjaKit 0.8), Opera 11.50 on Windows 7 Enterprise 32bit
// @charset UTF-8
// @version 0.0.3.20110715134929
// ==/UserScript==
@kkung
kkung / app.py
Created May 27, 2011 09:34
Flask, session store in memcached
from flask import Flask, request, session, url_for, redirect, \
render_template, abort, g, flash
from werkzeug.contrib.sessions import Session, SessionStore
from cPickle import HIGHEST_PROTOCOL
from random import random
from flask import json
class MemcachedSessionStore(SessionStore):
def __init__(self, servers=None, key_prefix=None, default_timeout=300):