Skip to content

Instantly share code, notes, and snippets.

View falsetru's full-sized avatar

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

View GitHub Profile
@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):
@falsetru
falsetru / main.py
Last active August 29, 2015 13:56
touchtracer
#!/usr/bin/kivy
import kivy
#kivy.require('1.0.6')
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label
from kivy.graphics import Color, Rectangle, Point, GraphicException
from kivy.clock import Clock
from kivy.logger import Logger
@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 / 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 / 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()
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)
import lxml.html
import requests
FILENAME = '3.png'
r = requests.get('http://www.onlinebarcodereader.com/')
root = lxml.html.fromstring(r.text)
MAX_FILE_SIZE, = root.cssselect('input[name=MAX_FILE_SIZE]')
senderid, = root.cssselect('#senderid')
import collections
import sys
def is_valid_fastq(lines):
return (
lines[0].startswith('@') and
lines[2].startswith('+') and
len(lines[1]) == len(lines[3])
)
#include <stdio.h>
#include <algorithm>
#define swc(i) (1L << (i * 3))
long long switches[10] = {
swc(0) | swc(1) | swc(2),
swc(3) | swc(7) | swc(9) | swc(11),
swc(4) | swc(10) | swc(14) | swc(15),
swc(0) | swc(4) | swc(5) | swc(6) | swc(7),
swc(6) | swc(7) | swc(8) | swc(10) | swc(12),
@falsetru
falsetru / submit.py
Last active December 13, 2015 11:38
submit solution to algospot judge.
#!/usr/bin/env python
import cookielib
import os
from contextlib import closing
import re
import getpass
import webbrowser
import sys