Skip to content

Instantly share code, notes, and snippets.

View s-hiiragi's full-sized avatar

s_hiiragi s-hiiragi

View GitHub Profile
@s-hiiragi
s-hiiragi / sample_destructive_methods.hsp
Created November 3, 2011 10:22
Destructive Named Methods Sample
;sample_destructive_methods
;
;名前に「!」が付いているメソッドは破壊的メソッド
#module destm a, b
#modfunc 更新! int x, int y
a = x
b = y
return
#modfunc 表示
@s-hiiragi
s-hiiragi / count_line.py
Created August 18, 2012 03:53
count line
import glob
if __name__ == '__main__':
paths = glob.glob('./*/data/*.csv')
cnt = 0
for path in paths:
with open(path, 'r') as f:
cnt += reduce(lambda x,y: x+1, f, 0)
print cnt
@s-hiiragi
s-hiiragi / 千反田える.js
Created November 30, 2012 18:31
千反田える
/**
* @name 千反田える.js
* @author s_hiiragi
* @created_date 2012/11/07 02:13
*/
/* Usage:
*
* node 千反田える.js {options}
*
@s-hiiragi
s-hiiragi / class4js.js
Created October 20, 2013 07:55
クラスベースオブジェクト指向 on JavaScript
console.log( 'クラスベースオブジェクト指向 on JavaScript' );
console.group( 'Functionを使う方法' );
(function() {
console.group( '(1) A, B, Cクラス兼コンストラクタとクラスメソッドを定義' );
console.log( 'CはBを継承, BはAを継承する' );
function A() { /* 初期化処理 */ }
A.intro = function() { console.log('A'); };
#!/bin/bash
# カレントディレクトリのすべてのファイルのTab文字をスペースに変換するワンライナー
find -maxdepth 1 -type f | grep -v "\.bak$" | while read f; do expand -t 4 "$f" > "$f.bak"; mv "$f.bak" "$f"; done
@s-hiiragi
s-hiiragi / exec_sample.go
Created February 6, 2017 00:00
Goで外部コマンドを実行して標準出力を得るサンプル
package main
import (
"fmt"
"log"
"os/exec"
)
func main() {
out, err := exec.Command("ls", "-l").Output()
@s-hiiragi
s-hiiragi / csv_read_sample.go
Last active February 6, 2017 12:19
GoでCSVファイルを読み込むサンプル
package main
import (
"fmt"
"os"
"io"
"encoding/csv"
)
func main() {
@s-hiiragi
s-hiiragi / regexp_sample.go
Last active February 6, 2017 12:21
Goで正規表現にマッチする文字列を取り出すサンプル
package main
import (
"fmt"
"regexp"
)
func main() {
fmt.Println("Hello, playground")
@s-hiiragi
s-hiiragi / flagset_sample.go
Last active February 6, 2017 12:21
Goで配列をコマンドラインとしてパースするサンプル
package main
import (
"flag"
"fmt"
)
func main() {
var (
boolFlag bool
@s-hiiragi
s-hiiragi / flag_sample.go
Created February 6, 2017 15:12
Goでコマンドライン引数をパースするサンプル
/*
* $ go run flag_sample.go -i 100 -s "strflag" 1 2 3
* os.Args: [/.../os_args_sample -i 100 -s strflag 1 2 3]
* flag.Args: [1 2 3]
* b: false
* i: 100
* s: strflag
*/
package main