Skip to content

Instantly share code, notes, and snippets.

@hktechn0
hktechn0 / ascii.c
Created December 13, 2009 18:32
print all printable ascii chars
#include <stdio.h>
int main(void)
{
int i;
for(i = 0x20; i < 0x7f; i++) {
printf("%c", i);
}
printf("\n");
@hktechn0
hktechn0 / usb_wsim-pathch.diff
Created December 13, 2009 12:52
kernel module patch for IODATA USB-WSIM
diff -ur linux-source-2.6.30/drivers/usb/serial/pl2303.c linux-source-2.6.30-mod/drivers/usb/serial/pl2303.c
--- linux-source-2.6.30/drivers/usb/serial/pl2303.c 2009-12-04 07:22:40.000000000 +0900
+++ linux-source-2.6.30-mod/drivers/usb/serial/pl2303.c 2009-12-12 00:10:37.000000000 +0900
@@ -60,6 +60,7 @@
{ USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) },
{ USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) },
{ USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
+ { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_UWSIM) },
{ USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
{ USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
#!/usr/bin/env python
def test1(id, **kwargs):
print id, kwargs
def test2(*args, **kwargs):
print args
print kwargs
def test3(id, name, mail,
@hktechn0
hktechn0 / print_dict.py
Created December 7, 2009 07:10
print dict for python
#!/usr/bin/env python
def print_dict(dic, h = ""):
print "%s{" % h
for d in dic:
print " %s%s\t:" % (h, d),
if isinstance(dic[d], dict):
print ""
print_dict(dic[d], h + " ")
else:
@hktechn0
hktechn0 / oauth-twitter.py
Created December 2, 2009 14:51
OAuth for Twitter
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import time, random
import urllib, urllib2
import hmac, hashlib
import cgi
#
# OAuth Module for Twitter
@hktechn0
hktechn0 / newinput.py
Created November 27, 2009 17:58
curses multibyte input method for Python
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import curses
def mbgetstr(stdcur, sety, setx, debug = False):
s = u""
i = 0
curses.noecho()
@hktechn0
hktechn0 / oauth.py
Created November 25, 2009 20:01
Twitter OAuth Sample Script
import time, random
import urllib, urllib2
import hmac, hashlib
import cgi
#
# Twitter OAuth Sample Script
# * techno - Hirotaka Kawata
# * http://techno-st.net/
#
@hktechn0
hktechn0 / post_status.py
Created November 24, 2009 21:01
Test script of impersonation from ~ on twitter
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import twitter
#==============================
# Settings
USER = ""
PASS = ""
#==============================
@hktechn0
hktechn0 / convert_utf8_to_unicode.py
Created November 10, 2009 17:01
Convert int or long UTF-8 code to Unicode character on Python.
def utf2ucs(utf):
if utf & 0x80:
# multibyte
buf = []
while not(utf & 0x40):
buf.append(utf & 0x3f)
utf >>= 8
buf.append(utf & (0x3f >> len(buf)))
ucs = 0
@hktechn0
hktechn0 / is_ascii.py
Created November 10, 2009 16:58
isascii() on Python
def isascii(c, printable = False):
if 0x00 <= ord(c) <= 0x7f:
if printable:
if 0x20 <= ord(c) <= 0x7e:
return True
else:
return False
else:
return True
else: