Skip to content

Instantly share code, notes, and snippets.

View yanbe's full-sized avatar

yanbe

View GitHub Profile
@yanbe
yanbe / .emacs
Created November 22, 2008 07:08
My .emacs file
(if window-system
(progn
(set-background-color "Black")
(set-foreground-color "LightGray")
(set-cursor-color "Gray")
(set-frame-parameter nil 'alpha 80)))
(setenv "PATH"
(concat "/usr/local/flex3sdk/bin:"
"/usr/local/bin:"
@yanbe
yanbe / dilbert.py
Created November 24, 2008 09:52
Download all dilbert comics from 1900-1-1 to today
#!/usr/bin/env python
import urllib2
import datetime
offset = 33039 #initial id
first = datetime.datetime(1990,1,1) #initial date
today = datetime.datetime.today()
for i in xrange(offset, offset+(today-first).days):
_dirs = [0]
for j in range(9,1,-1):
@yanbe
yanbe / wn.py
Created March 14, 2009 12:32
A frontend of WordNet-Ja database file (sqlite3 format) which is available on http://nlpwww.nict.go.jp/wn-ja/
#!/usr/bin/env python2.6
# encoding: utf-8
import sys
import sqlite3
from collections import namedtuple
conn = sqlite3.connect("wnjpn-0.9.db")
Word = namedtuple('Word', 'wordid lang lemma pron pos')
# An example of bootstrapping remote echo client via SSH connection
import socket
import subprocess
import sys
host = '192.168.1.20'
SSH_CLIENT = sys.platform=='win32' and 'plink' or 'ssh'
REMOTE_CODE = '''"import os, socket, sys
@yanbe
yanbe / youtube.py.patch
Created April 24, 2009 05:23
patch for Totem YouTube plugin that enables HD movies a.k.a &fmt=22.
--- youtube.py.orig 2009-04-24 12:40:50.861929605 +0900
+++ youtube.py 2009-04-25 02:35:27.190928256 +0900
@@ -3,6 +3,7 @@
gobject.threads_init()
import gdata.service
import urllib
+import urllib2
import httplib
import atom
import threading
@yanbe
yanbe / .Xmodmap
Created April 28, 2009 09:41
map Enter as right Control modifier. shift+Enter as ordinal Enter
add control = Return
keycode 36 = Control_R Return Control_R Return Control_R Return
@yanbe
yanbe / fillrect.c
Created June 16, 2009 06:29
From given size of area and rect, examine maximum number of rects can be contained in the area, and print its pattern.
/* From given size of area and rect, examine maximum number of rects can be
contained in the area, and print its pattern.
( answer for a programming question at http://q.hatena.ne.jp/1245118420 )
*/
#include <stdlib.h>
#include <stdio.h>
int do_num_contain_rect(int aw, int ah, int w, int h)
{
if (w>aw || h>ah) return 0;
@yanbe
yanbe / python-chmhelp.el
Created July 1, 2009 09:31
CHM file support for python-mode on Emacs
;; CHM file support for Python help
;; Prerequisites: hhh.exe http://saitou155.catfood.jp/hhh.htm
;; TODO: support Mac and Linux
(require 'python-mode)
(defcustom py-chmhelp-path "/Python26/Doc/python262.chm"
"path for Python CHM help file"
:type 'string
:group 'python)
@yanbe
yanbe / A 200 lines Twitter client in Python featuring ballon notification on GNOME
Created July 28, 2009 06:51
A 200 lines Twitter client in Python featuring ballon notification on GNOME
#!/usr/bin/env python
# Your account information
username=""
password=""
# screen_resolution is used for balloon positioning
screen_resolution=1024,768
# Minimum update_interval under Twitter API restriction is 60*60/70=51.4
update_interval=52
# Balloon will disapear after notify_timeout seconds
@yanbe
yanbe / userstreams.go
Created July 20, 2010 10:43
Reads ChirpUserStreams continuously, format chunks, then put them into standard output.
/*
userstreams.go: Reads ChirpUserStreams continuously, format tjem, then put them
into standard output. For detail, read:http://apiwiki.twitter.com/ChirpUserStreams .
Author: Yusuke Yanbe (y.yanbe@gmail.com)
*/
package main
import (