Skip to content

Instantly share code, notes, and snippets.

View falsetru's full-sized avatar

이정민(Jeong-Min Lee) / SWAT falsetru

View GitHub Profile
class CurriedProc < Proc
attr_accessor :arity
def parameters
(1..arity).map { |i| [:opt, "_#{i}".to_sym] }
end
end
class Proc
def bind(pos, value)
raise ArgumentError.new("wrong position of argument (#{pos} for #{arity})") unless (1..arity).include?(pos)
@falsetru
falsetru / test_selenium_webdriverwait.py
Created August 31, 2013 14:17
test WebDriverWait
# See https://code.google.com/p/selenium/source/browse/py/selenium/webdriver/support/wait.py
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
driver = webdriver.Firefox()
driver.get('http://jsfiddle.net/falsetru/M6tdQ/show/')
WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id('status').text == 'ready')
driver.execute_script('alert("done")')
#driver.quit()
@falsetru
falsetru / ex.py
Last active December 23, 2015 03:59 — forked from Hardtack/ex.py
functions = []
for val in ['foo', 'bar', 'baz']:
def f(val=val):
return val
functions.append(f)
for func in functions:
print(func())
@falsetru
falsetru / 3n_1.py
Created October 16, 2013 07:53
우박 수열
import functools
import sys
@functools.lru_cache(maxsize=None) # Python 3.2+
def f(n):
if n == 1:
return 1
elif n % 2 == 0:
return 1 + f(n // 2)
else:
@falsetru
falsetru / datameta.py
Last active December 7, 2018 14:28 — forked from tempKDW/datameta.py
Use `new_attrs` when creating __slots__
class DataMeta(type):
def __new__(cls, name, bases, attrs):
def check_type(k, v):
cls._validate(attrs[k]['type'], v)
def set_default(self, kwargs):
for key_meta, value_meta in attrs.items():
if key_meta.startswith('__') and key_meta.endswith('__'):
continue
if not isinstance(value_meta, dict):