This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from gettext import NullTranslations | |
import argparse, sys | |
argparse.str = lambda s: s.encode(sys.stdout.encoding) if isinstance(s, unicode) else s | |
CATALOGUE = dict([ | |
('usage: ', | |
u'使い方: '), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import os | |
import sys | |
import urllib | |
import tarfile | |
import time | |
from xml.etree import ElementTree as ET | |
from StringIO import StringIO | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
hellox -- Hello world with Xlib. | |
$(CC) -o hellox hellox.c -lX11 -L/usr/X11/lib | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
pthtest --- hello pthread. | |
gcc -pthread -o pthtest pthtest.c | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32com.client, time, binascii | |
Agent = win32com.client.Dispatch("Agent.Control.2") | |
Agent.Connected = 1 | |
Agent.Characters.Load("Merlin", "C:\WINDOWS\MSAGENT\CHARS\MERLIN.ACS") | |
Merlin = Agent.Characters("Merlin") | |
Merlin.Show() | |
bdat = [ \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import sys | |
offset = 0xe000 | |
sys.stdout.write(('|'.join([unichr(offset+i) for i in range(256)])).encode('utf-8')) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import wx | |
class MyDirCtrl(wx.GenericDirCtrl): | |
def __init__(self, *args, **kwargs): | |
wx.GenericDirCtrl.__init__(self, *args, **kwargs) | |
tree = self.GetTreeCtrl() | |
tree.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnTreeExpanded) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
"""とこちゃんはどこ | |
""" | |
from random import choice, randrange | |
import random, sys | |
s = ["と", "こ", "ち", "ゃ", "ん"] | |
def tokochan(width, height): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
To parse XML with namespaces using ElementTree, keeping namespace prefix, you will need register_namespace. | |
>>> from xml.etree.ElementTree import register_namespace, fromstring, tostring | |
>>> base_ns = { | |
... 'http://example.com/article': 'article', | |
... 'http://example.com/report': 'report', | |
... 'http://example.com/book': 'book', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# do HTTP digest login | |
sub digest_login_request { | |
my ($schema, $username, $pw_override) = @_; | |
my $res = request('/login'); | |
my %digest_hdr = map { | |
my @key_val = split /=/, $_, 2; # / | |
$key_val[0] = lc $key_val[0]; | |
$key_val[1] =~ s{"}{}g; # remove the quotes | |
@key_val; | |
} split /,\s?/, substr( $res->header('WWW-Authenticate'), 7 ); #/; |
OlderNewer