This file contains hidden or 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/env python | |
# vim: set fileencoding=utf8 : | |
"""Singleton Mixin""" | |
class Singleton(object): | |
"""Singleton Mixin Class | |
Inherit this class and make the subclass Singleton. | |
Usage: |
This file contains hidden or 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
class Attrdict(dict): | |
"""Attribute accessible dictionary class | |
Usage: | |
>>> attrdict = Attrdict(alice='in the wonderland') | |
>>> attrdict.alice | |
'in the wonderland' | |
>>> attrdict['hello'] = 'world' | |
>>> attrdict['hello'] | |
'world' |
This file contains hidden or 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
#!/bin/sh | |
# --- long way | |
ROOT=`dirname $0` | |
ROOT=`cd $ROOT;pwd` | |
# --- short way | |
ROOT=$(cd $(dirname $0);pwd) | |
# --- with readlink | |
SELF=$(readlink -f $0) |
This file contains hidden or 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
Array::fold = (f, init)-> | |
c = init | |
for e in this | |
c = f(e, c) | |
c | |
if Array::reduce is undefined | |
Array::reduce = (f) -> @[1..].fold(f, @[0]) | |
sum = (a)-> |
This file contains hidden or 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
toDegree = (rad) -> | |
# Convert radian to degree | |
rad * 180 / Math.PI | |
toRadian = (deg) -> | |
# Convert degree to radian | |
deg * Math.PI / 180 |
This file contains hidden or 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
#!coffee | |
# | |
# required | |
# - vector.coffee - gist: 1177722 | |
# | |
vector = require './vector' | |
isCollided = (sector, point) -> | |
# Collision detection of circular sector and point | |
toRadian = (d) -> d * Math.PI / 180 |
This file contains hidden or 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
#!coffee | |
# | |
# Convert multidimensional array to one dimensional array. | |
# Return an empty list when passed array is an empty list. | |
# | |
# Usage:: | |
# | |
# assert = require 'assert' | |
# matrix = [ |
This file contains hidden or 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
# iBUS | |
#export XMODIFIERS="@im=ibus" | |
#export GTK_IM_MODULE="ibus" | |
#export QT_IM_MODULE="xim" | |
#ibus-daemon -d -x | |
# uim | |
export XMODIFIERS="@im=uim" | |
export GTK_IM_MODULE="uim" | |
export QT_IM_MODULE="uim" |
This file contains hidden or 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
#!/bin/bash | |
PLATFORM=`uname` | |
PYTHON_VERSION=2.7.2 | |
if [ "$PLATFORM" = 'Linux' ]; then | |
echo "Installing required packages..." | |
yes | sudo apt-get install curl python-all-dev python3-all-dev | |
yes | sudo apt-get install libreadline6-dev libsqlite3-dev libgdbm-dev | |
yes | sudo apt-get install libbz2-dev build-essential libxml2-dev libxslt1-dev | |
# Patch for PIL |
This file contains hidden or 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
#!/bin/bash | |
echo "Please input your virtual machine name" | |
read NAME | |
SSH=2222 | |
HTTP=8080 | |
# SSH | |
VBoxManage setextradata "$NAME" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/Protocol" TCP | |
VBoxManage setextradata "$NAME" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/GuestPort" 22 | |
VBoxManage setextradata "$NAME" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/HostPort" $SSH |
OlderNewer