Skip to content

Instantly share code, notes, and snippets.

View maeharin's full-sized avatar

Hidenori Maehara maeharin

View GitHub Profile
@maeharin
maeharin / pointer.c
Created December 21, 2012 03:33
practice c pointer
#include <stdio.h>
int main(void)
{
int x = 1;
int *p = &x;
printf("%d\n", x);
printf("%p\n", &x);
printf("%d\n", *&x);
@maeharin
maeharin / ruby_oneliner.sh
Last active December 10, 2015 04:08
ruby one liner
# directory name
ls -laF | ruby -e '$stdin.read.scan(%r![\S]+/!) {|m| puts m}'
# or
ls -laF | ruby -ne 'puts $_.split("\s")[8]'
@maeharin
maeharin / 2ch.sh
Last active December 10, 2015 04:58
ruby -r open-uri -e 'open("http://uni.2ch.net/newsplus/") {|f| puts f.read.scan(/<a.+?>\d+?:\s(.+?)</)}' | nkf -w
ruby -r open-uri -e 'open("http://b.hatena.ne.jp/hotentry") {|f| puts f.read.scan(/entry-link.+?>(.+?)</)}' | sed -e "s/続きを読む//g"
ruby -r open-uri -e 'open("http://www.yahoo.co.jp") {|f| puts f.read.scan(/topics.+?>(.+?)</)}'
ruby -r pp -e 'pp ENV.to_hash'
#coding: utf-8
class M1
def initialize(app)
@app = app
end
def call(env)
env = env + '1'
res = @app.call(env)
@maeharin
maeharin / autosplit.sh
Created December 28, 2012 01:57
スペース区切りのテキストファイルを読み込んで、各行の最初の列だけ抜き出し、新たなファイルに保存
ruby -ane 'puts $F[0]' hoge.txt > hoge2.txt
find ./ -name 'filename'
grep -irs 'query' ./
<?php
class C
{
public function foo() {
echo "foo";
}
}
$c = new C();