Skip to content

Instantly share code, notes, and snippets.

View hfm's full-sized avatar

Okumura Takahiro hfm

View GitHub Profile
@hfm
hfm / setPATH.diff
Created July 8, 2012 15:31
Homebrewインストールの手順
$ vi .zshrc
+ export PATH=/usr/local/bin:/usr/local/sbin:$PATH
$ source .zshrc
$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:...
@hfm
hfm / gist:3071715
Created July 8, 2012 16:39
Homebrew経由でCoffee-Scriptを入れる方法
# Node.jsをHomebrewから入れる
$ brew install node
# NPM(Node Package Manager)を入れる
$ sudo curl http://npmjs.org/install.sh | sh
# 環境変数を設定する(Zshの場合)
$ vi .zshrc
+ export NODE_PATH=/usr/local/lib/node_modules
$ source .zshrc
@hfm
hfm / UIActionSheet_normal.m
Created July 8, 2012 17:25
UIActionSheetのキャンセルボタンを最下部に設定する(ユニバーサル仕様)
// UIActionSheetクラスを作成する
// cancelButtonとdestructiveButtonはどちらかをnilにしておく
UIActionSheet *sheet;
sheet = [[UIActionSheet alloc] initWithTitle:@"写真選択"
delegate:self
cancelButtonTitle:@"キャンセル"
destructiveButtonTitle:nil
otherButtonTitles:@"カメラ", @"ライブラリ", nil];
[sheet showInView:self.view];
@hfm
hfm / addconfig.diff
Created July 9, 2012 11:25
Gitolite Install on FreeBSD
$ vi ~/.ssh/config
+ Host gitolite
+ HostName ***.***.***.***
+ User git
+ Port ****
+ IdentityFile ~/.ssh/gitolite
@hfm
hfm / uninstall_homebrew.sh
Created July 14, 2012 12:22 — forked from mxcl/uninstall_homebrew.sh
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@hfm
hfm / backend.conf
Created July 27, 2012 14:52
NGINX Reverse Proxy
server {
listen ****; #8080とか8001とか
server_name ****;
# Root
location / {
root /usr/local/www/;
index index.html index.htm;
if (-f $request_filename) {
expires 30d;
@hfm
hfm / backend.conf
Created July 27, 2012 16:16
Wordpress and NGINX with Reverse Proxy
server {
listen ****; # 80番以外の競合しないポート
server_name blog.hifumi.info;
client_max_body_size 20M;
# Root
location / {
root /usr/local/www/wordpress;
index index.html index.htm index.php;
if (-f $request_filename) {
@hfm
hfm / BaseCell.h
Created October 29, 2012 02:56
Snipped Customised UITableViewCell
// Inspired by http://stackoverflow.com/questions/540345/how-do-you-load-custom-uitableviewcells-from-xib-files
#import <UIKit/UIKit.h>
@interface BaseCell : UITableViewCell
/* Load Cell-Object from Nib-Name */
+ (BaseCell*)cellFromNibNamed:(NSString *)nibName;
@end
@hfm
hfm / hellinger.py
Created November 2, 2012 12:07 — forked from larsmans/hellinger.py
Hellinger distance for discrete probability distributions in Python
"""
Three ways of computing the Hellinger distance between two discrete
probability distributions using NumPy and SciPy.
"""
import numpy as np
from scipy.linalg import norm
from scipy.spatial.distance import euclidean
@hfm
hfm / em.py
Created November 5, 2012 15:34 — forked from showyou/em.py
EM Algorithm
import numpy as np
import numpy.random as rand
import matplotlib.pyplot as plt
def mixture_gaussian(i):
pi_0 = 0.3
if rand.random() < pi_0:
return rand.normal(-5, 1)
else: