Skip to content

Instantly share code, notes, and snippets.

View longfin's full-sized avatar

Swen Mun longfin

View GitHub Profile
<link rel="import" href="../chart-js/chart-js.html">
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@longfin
longfin / gist:2405176b938ee6d816d0
Last active August 29, 2015 14:06
파이썬 서버 실행법
1. `Win` + `R` 키나 `시작` > `실행` 버튼을 눌러 `cmd` 를 입력합니다.
2. 실행된 창에 `cd <프로젝트 디렉토리>` 를 입력하고 엔터를 입력합니다.
- (e.g. `C:\Users\Student1\포트폴리오` 가 프로젝트 디렉토리인 경우 `cd C:\Users\Student1\포트폴리오`)
- 프로젝트 디렉토리는 `app.py` 와 `template` 등의 디렉토리가 보이는 디렉토리를 말합니다.
3. `python app.py` 를 입력하고 엔터를 입력합니다.
- 이 때 `내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치파일이 아닙니다.` 라는 메시지가 뜨면 python 을 설치해야합니다.
4. 웹 브라우저를 열어 `http://localhost:5000` 을 입력합니다.
@longfin
longfin / todo.html
Created October 7, 2014 02:02
react-tutorial
<!DOCTYPE html>
<html>
<head>
<style>
span.done {
text-decoration: line-through;
}
</style>
</head>
<body>
class Car:
def __init__(self, type):
self.type = type
class License:
def __init__(self, driver_name):
self.driver_name = driver_name
def print(self):
print("{}의 {}종 면허입니다.".format(self.driver_name, self.LICENSE_TYPE))
(defn split [seq delimiter]
(letfn [(check-non-delimiter [val] (not (= val delimiter)))]
(cond
(empty? seq)
seq
(every? check-non-delimiter seq)
(list seq)
:default
(cons
(take-while check-non-delimiter seq)
@longfin
longfin / gist:1422196
Created December 2, 2011 07:29
딱히 의도한건 아니지만 메모삼아...
from collections import deque, Iterable
def flatten(l):
"""
>>> [i for i in flatten([1, [2,3], [5, [6,7]]])]
[1, 2, 3, 5, 6, 7]
"""
queue = deque(l)
while len(queue) > 0:
p = queue.popleft()
@longfin
longfin / gist:1426133
Created December 3, 2011 05:11
요런 식으로 sqlalchemy의 joinedload, subqueryload를 바꿔치기함
from functools import wraps
def __extend_keys(l):
ret = [[]]
for p in l:
for r in list(ret):
if isinstance(p, list):
ret.remove(r)
for e in p:
nr = list(r)
@longfin
longfin / gist:1441283
Created December 7, 2011 03:18
Class Factory?
TAG_TYPES = ["location", "category"]
class Tag(db.Model, BaseEntityMixIn,
IgnoreDeletionMixIn):
__tablename__ = "tag"
name = db.Column(db.Unicode(255), index=True)
type = db.Column(db.Enum(*TAG_TYPES, native_enum=False), index=True)
__mapper_args__ = {'polymorphic_on': type}
g = globals()
@longfin
longfin / gist:1455788
Created December 10, 2011 18:04
kmp search
"""
http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm
"""
def kmp_make_table(word):
table = len(word) * [0]
pos = 2
cnd = 0
table[0] = -1
table[1] = 0
@longfin
longfin / gist:1606034
Created January 13, 2012 13:11
very simple wsgi application
def app(environ, start_response):
response_body = 'Hello World!'
status = '200 OK'
response_headers = [('Content-Type', 'text/plain'),
('Content-Length', str(len(response_body)))]
start_response(status, response_headers)
return [response_body]