Skip to content

Instantly share code, notes, and snippets.

View raimon49's full-sized avatar
🍺
lovecraftbeer

raimon raimon49

🍺
lovecraftbeer
View GitHub Profile
@raimon49
raimon49 / nkf-oneliner.sh
Created February 6, 2011 14:26
直下のhtmlファイルを全部nkfに渡してutf-8 LFに変換するワンライナー
find . -name "*.html" -print0 | xargs -0 nkf -w -Lu --overwrite
@raimon49
raimon49 / latlngcontrol.coffee
Created February 21, 2011 13:33
LatLng/Pixel Coordinate Custom Control
class LatLngControl extends google.maps.OverlayView
constructor: (map) ->
@ANCHOR_OFFSET_ = new google.maps.Point 8, 8
@node_ = @createHtmlNode_()
map.controls[google.maps.ControlPosition.TOP].push @node_
@setMap map
@set 'visible', false
draw: ->
@raimon49
raimon49 / sort_hist
Created March 1, 2012 13:35
zshの履歴から良く打ってる順にコマンド + サブコマンド( or オプション)を並べるワンライナー
cat ~/.zsh_history | awk '{print $1" "$2}' | sort | uniq -c | sort -nr | head -20
@raimon49
raimon49 / non-super.py
Created March 5, 2012 13:26
明示的に親クラスの__init__()を呼び出し
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# super 使わない
class Base(object):
def __init__(self):
print('Base')
@raimon49
raimon49 / use-super.py
Created March 5, 2012 13:27
super()経由でSubの親であるBaseの__init__()を呼び出す
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# super 使う(Function.prototype.apply みたいな動き)
class Base(object):
def __init__(self):
print('Base')
@raimon49
raimon49 / hgeditor.diff
Created March 20, 2012 07:38
Take2: 日本語設定でhg commit時にvimで差分を見ながら入力するパッチ(最新版との差分 + 恥ずかしいデバッグプリントを削除)
--- hgeditor.latest 2012-08-22 23:08:18.007214610 +0900
+++ hgeditor 2012-08-22 23:08:27.607219725 +0900
@@ -12,11 +12,15 @@
emacs)
EDITOR="$EDITOR -nw"
;;
- gvim|vim)
- EDITOR="$EDITOR -f -o"
- ;;
esac
@raimon49
raimon49 / tmp.pl
Created May 10, 2012 03:40
Perlでパイプから受け取った内容を一時ファイルに書き出してほげほげする
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Temp qw(tempfile);
my $fh;
my $f;
unless ( -t STDIN) {
($fh, $f) = tempfile(
@raimon49
raimon49 / create_tzinfo.py
Created July 7, 2012 06:32
動的にtzinfoサブクラスを作ってdatetimeオブジェクトを異なるタイムゾーンに変換する
#!/usr/bin/env python
from datetime import *
def create_tzinfo(name, offset_hours=0, offset_dst=0):
my_tzinfo = type(name, (tzinfo, ), {})
my_tzinfo.utcoffset = lambda self, dt: timedelta(hours=offset_hours)
my_tzinfo.dst = lambda self, dt: timedelta(offset_dst)
my_tzinfo.tzname = lambda self, dt: name
return my_tzinfo
@raimon49
raimon49 / commit_sort.sh
Created August 21, 2012 05:40
svnのコミットログ回数のソート
svn log /path/to/repo -q | awk '/^r/ { print $3 }' | sort | uniq -c | sort -rn
@raimon49
raimon49 / MyClass.h
Last active October 10, 2015 10:08
Objective-C憶えたことのメモ
// vim:ft=objc:ts=2:sts=2:sw=2
@interface MyClass : NSObject
@property (nonatomic, readonly, copy) NSString *publicProperty;
@property (nonatomic, copy) NSString *protectedProperty;
- (void)pubilcMethod;
@end