Skip to content

Instantly share code, notes, and snippets.

import sched
import threading
import time
class test(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.setDaemon(True)
def run(self):
#!/usr/bin/env python
import threading
class main(threading.Thread):
def __init__(self, sec):
threading.Thread.__init__(self)
self.event = threading.Event()
self.sleep = sec
@hktechn0
hktechn0 / htmltitle.py
Created February 18, 2010 20:32
pick out title from HTML
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import urllib2
import HTMLParser
html = urllib2.urlopen(sys.argv[1]).read()
class titleparser(HTMLParser.HTMLParser):
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import curses
import locale
def test(stdcur):
stdcur.clear()
stdcur.addstr(0, 0, "abcde")
stdcur.addstr(1, 0, "あいうえお")
#!/usr/bin/env python
def test():
print "Hello."
return True
a = {10 : "0x1010"}
# k in a
print a.get(10, test()) # :True
print a.get(100, test()) # :False
#!/usr/bin/env python
import threading
import time
class test(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.setDaemon(True)
self.i = 0
#!/usr/bin/env python
import threading
import time
class test(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.i = 0
@hktechn0
hktechn0 / pil_image_urllib2.py
Created February 5, 2010 20:44
PIL Image get from web (urllib2)
#!/usr/bin/env python
import urllib2
import Image
import cStringIO
imgdata = urllib2.urlopen("http://www.google.co.jp/intl/ja_jp/images/logo.gif").read()
img = Image.open(cStringIO.StringIO(imgdata))
img.save("goog.png")
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
ModulePath "/usr/lib64/xorg/modules"
FontPath "catalogue:/etc/X11/fontpath.d"
#!/usr/bin/env python
import datetime
loop = 500000
a = str()
s = datetime.datetime.now()
for i in range(loop):