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
from google.appengine.ext import db | |
class ReferenceProperty(db.ReferenceProperty): | |
"""A property that represents a many-to-one reference to another model. | |
This class has serveral enhancement on | |
google.appengine.ext.db.ReferenceProperty. | |
1. Its object returns None when referenced entity does not exist, nstead | |
of raising ReferencePropertyResolveError. |
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
class DotDict(dict): | |
def __getattr__(self, attr): | |
return self.get(attr, None) | |
__setattr__= dict.__setitem__ | |
__delattr__= dict.__delitem__ |
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 set_trace(): | |
import pdb, sys | |
debugger = pdb.Pdb(stdin=sys.__stdin__, | |
stdout=sys.__stdout__) | |
debugger.set_trace(sys._getframe().f_back) |
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
from datetime import datetime, timedelta | |
from google.appengine.ext import db | |
class Foo(db.Model): | |
value = db.DateTimeProperty() | |
db.delete(Foo.all()) | |
Foo(value=None).put() | |
Foo(value=datetime.now()).put() |
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
# coding: utf8 | |
"""pelo | |
pelo branch management wrapper commands | |
""" | |
from datetime import datetime | |
from mercurial import commands | |
HELP_DOC = """COMMAND OPERATION [label] |
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
javascript:( | |
function(){ | |
var url = document.location.toString(); | |
var title_start_pattern = /(#.+)/; | |
var title_end_pattern = /- [^-]+ - Redmine/; | |
document.title.match(title_start_pattern); | |
RegExp.lastMatch.match(title_end_pattern); | |
var title = RegExp.leftContext; | |
var elements = document.getElementsByClassName('due-date'); | |
var due = elements[1].firstChild.nodeValue; |
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 boto.ec2 | |
c = boto.ec2.connect_to_region('ap-northeast-1', | |
aws_access_key_id=aws_access_key_id, | |
aws_secret_access_key=aws_secret_access_key) | |
reservations = c.get_all_instances() | |
instances = [item for sublist in reservations for item in sublist.instances] | |
for instance in instances: | |
if instance.state != 'running': | |
continue |
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
;;; -*- coding: utf-8 -*- | |
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(column-number-mode t) | |
'(show-paren-mode t) | |
'(tool-bar-mode nil) |
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
div#header-inner div.titlewrapper { | |
margin-left: 2px; | |
padding-bottom: 0px; | |
} | |
div.header-outer .descriptionwrapper { | |
width: 500px; | |
} | |
div#header-inner div.descriptionwrapper { |
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
{ | |
"author": { | |
"name": "wozozo", | |
"position": "co-founder" | |
}, | |
"message": "hello" | |
} |