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
# extended zipfile module to handle sjis damemoji well. | |
from zipfile import * | |
def cp932_invert(cp932_path): | |
from string import printable | |
def fun(i): | |
pred = i > 0 and cp932_path[i] == '/' and cp932_path[i-1] not in printable | |
return '\\' if pred else cp932_path[i] | |
lst = map(fun, range(len(cp932_path))) | |
uni = ''.join(lst).decode('cp932').replace('\\', '/') |
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 urllib | |
import decimal | |
import re | |
import time | |
from BeautifulSoup import BeautifulSoup as BS | |
class SievertPerHour(object): | |
def __init__(self, sv): | |
if isinstance(sv, decimal.Decimal): |
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
// usage: | |
// | |
// TesseractOCR ocr = TesseractOCR(@"C:\bin\tesseract.exe"); | |
// string result = ocr.OCRFromBitmap(bmp); | |
// textBox1.Text = result; | |
// | |
using System; | |
using System.IO; | |
using System.Diagnostics; | |
using System.Drawing; |
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
using System.Drawing; | |
using System.Drawing.Imaging; | |
namespace BitmapConversion | |
{ | |
static class GrayScale | |
{ | |
public static Bitmap Transform(Bitmap bmp, float[][] matrix) | |
{ | |
ColorMatrix mat = new ColorMatrix(matrix); |
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
from sys import stdin, stdout | |
# state | |
class Int(object): | |
def __init__(self, v=0): self.val = v | |
def set(self, v): self.val = v; return self.val | |
def inc(self): self.val += 1; return self.val | |
def dec(self): self.val -= 1; return self.val | |
mem = [Int() for i in range(255)] | |
stk = [] | |
ptr = Int() |
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 | |
# one dimensional cell automaton | |
import random | |
class Cell1Dim(object): | |
def __init__(self, rule, initializer): | |
# buffer | |
self.fore = initializer | |
self.back = [0] * len(initializer) |
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
// http://archive.linux.or.jp/JM/html/glibc-linuxthreads/man3/pthread_cond_wait.3.html | |
// http://d.hatena.ne.jp/mononoco/20080522/1211452506 | |
// http://codezine.jp/article/detail/1894?p=2 | |
#include<stdio.h> | |
#include<pthread.h> | |
typedef unsigned char byte_t; | |
typedef struct { | |
pthread_mutex_t mutex; | |
pthread_cond_t cond; |
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 urllib | |
import time | |
import json | |
import StringIO | |
import zipfile | |
# google code jam 2011 qualification round |
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
let g:user_zen_settings = { | |
\ 'html' : { | |
\ 'indentation' : ' ', | |
\ 'snippets' : { | |
\ 'gapi:jquery' : '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>', | |
\ 'gapi:jqueryui' : '<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>', | |
\ } | |
\ } | |
\} |
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
#!/usr/bin/python | |
# coding: utf-8 | |
# ref: http://stackoverflow.com/questions/582056/getting-list-of-parameters-inside-python-function | |
import inspect | |
def base(name, ptype, required): | |
def deco(fun): def gun(*args, **kwargs): frame = inspect.currentframe() _, _, _, values = inspect.getargvalues(frame) try: if required: values[name] = ptype(values[name]) | |
except Exception, e: | |
raise e | |
return fun(*args, **kwargs) |
OlderNewer