Skip to content

Instantly share code, notes, and snippets.

View itkr's full-sized avatar
:octocat:

Shota Itakura itkr

:octocat:
View GitHub Profile
import random
import string
import hashlib
source = string.digits + string.letters
letters = "".join([random.choice(source) for i in xrange(25)])
letters_hash = hashlib.sha256(letters).hexdigest()
print 'Letters =>', letters
print 'SHA-256 =>', letters_hash
function extend(Child, Parent) {
var NewParent = Parent;
if(typeof Parent.prototype.parent !== "undefined"){
NewParent = Animate.tools.extend(Parent, Parent.prototype.parent);
}
Child.prototype = new NewParent();
Child.prototype.parent = NewParent;
return Child;
}
var format = function(){
var i = 0;
var str = "";
for(i = 0; i < arguments.length; i++){
str = str + arguments[i];
}
return str;
};
local function getCenterPosition(baseNode, childNode)
local baseSize = baseNode:getContentSize()
local childSize = childNode:getContentSize()
return baseSize.width / 2 - childSize.width / 2,
baseSize.height / 2 - childSize.height / 2
end
git log --no-merges --date=short --pretty='format:%h %cd %an%d %s' master...HEAD | cat
@itkr
itkr / get3days.sql
Created August 18, 2014 06:38
日本時間を考慮して過去三日分のデータを取得する
select
id,
updated_at
from
foo_table
where
date(updated_at + interval 9 hour) between (current_date() - interval 3 day) and (current_date() - interval 1 day)
;
alias fd='find ./ -type f -print | xargs grep'
@itkr
itkr / gist:4ca1d1070a6fa87ba6c7
Created January 23, 2015 15:19
cached_property
def cached_property(func):
@property
def f(self):
name = "_{}_cache".format(func.__name__)
if not hasattr(self, name):
setattr(self, name, func(self))
return getattr(self, name)
return f
@itkr
itkr / template.html
Last active August 29, 2015 14:16
django template 日付
{{datetime_object|date:'n月j日 H:i'}}
@itkr
itkr / timetuple.py
Created April 16, 2015 07:19
timetuple
from datetime import datetime
import time
a = datetime.now()
# datetime.datetime(2015, 4, 16, 16, 15, 47, 92560)
b = int(time.mktime(a.timetuple()))
# 1429168547
datetime.fromtimestamp(b)