Skip to content

Instantly share code, notes, and snippets.

View maxtortime's full-sized avatar

Kim Taehwan maxtortime

View GitHub Profile
@maxtortime
maxtortime / models.py
Created August 8, 2016 23:33
flask-sqlalchemy 외래키 구현
# Define models
roles_users = db.Table('roles_users',
db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))
# Role table
class Role(db.Model, RoleMixin):
id = db.Column(db.Integer(), primary_key=True)
name = db.Column(db.String(80), unique=True)
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
@maxtortime
maxtortime / ipython
Created August 3, 2016 07:00
ipython authoreload
In [1]: %load_ext autoreload
In [2]: %autoreload 2
In [3]: from foo import some_function
In [4]: some_function()
Out[4]: 42
In [5]: # open foo.py in an editor and change some_function to return 43
#!env sh
base64 /dev/urandom | head -c 10000000 > 10MB.txt
(function() {
var num;
sorted(random.sample([
(function() {
var i, len, ref, results;
ref = range(1, 46);
results = [];
for (i = 0, len = ref.length; i < len; i++) {
num = ref[i];
@maxtortime
maxtortime / create_issue.sh
Last active June 9, 2016 14:17
creating new issue by postman
curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: 6eafe619-9856-1e4c-857f-3c7b8157e144" -d '{
"title": "New logo",
"body": "We should have one",
"labels": ["design"]
}' "https://api.github.com/repos/maxtortime/python-lotto/issues?access_token="
@maxtortime
maxtortime / remove_traling_newline.c
Created February 28, 2016 09:00
Remove trailing new line after fgets
/* Remove trailing newline, . */
if ((strlen(name)>0) && (name[strlen (name) - 1] == '\n'))
name[strlen (name) - 1] = '\0';