Skip to content

Instantly share code, notes, and snippets.

@ideodora
ideodora / gist:c36d5eba5de3d93edb90
Created October 10, 2014 16:56
既に管理下のファイルを.gitignoreに追加して無視したい時
#ただ、既に大量のファイルが登録されている場合、これをひとつひとつやっていたら大変なので、以下のように git ls-files の -i と --exclude-from オプションを使って、まとめて除外するとらくです。
git rm --cached `git ls-files --full-name -i --exclude-from=.gitignore`
#-i は --ignored の略で、Git に登録されているファイルの内、次に指定する方法で無視するファイルの一覧を出力します。
#--exclude-from=<ignore-file> を指定すると、<ignore-file> に記述されたパターンにマッチするファイルを、無視するファイルとして扱います。
#--exclude-standard を指定すると、Git が標準で無視リストとして扱う .gitignore や .git/info/exclude などのファイルに書かれたパターンにマッチするファイルを、無視するファイルとして扱います。
@ideodora
ideodora / gist:ebd4a5216e7d28bf7193
Created October 10, 2014 11:48
Node.js 外部コマンド
# 1. Streamっぽく
spawn = require('child_process').spawn
spawn 'cmd', ['arg1','arg2'], ['-op1','-op2']
spawn.stdout.on 'data', (data) ->
# todo
# 2. Callbackっぽく
exec = require('child_process').exec
exec 'cmd arg arg -op1 -op2', (err, stdout, stderr) ->
# todo
from datetime import date
from calendar import monthrange
def get_last_date(year, month):
# monthrange は月の1日の曜日と日数を返してくれる
# 日数を date に渡せば月末の日付のできあがり
youbi, day = monthrange(year, month)
last = date(year, month, day)
return last
@ideodora
ideodora / gist:3c01cc4faf0709c0c4dc
Created October 10, 2014 11:15
datetime.date 型
import datetime
today = datetime.date.today() # 今日の日付けのdate型を作成
# 任意の数値を変えたdateを返す
Year2013SameDay = today.replace(year=2013)
Month12SameDay = today.replace(month=12)
firstDay = today.replace(day=1)
# 0001年01月01日からの経過日数
$telnet yahoo.co.jp 80
>GET / HTTP/1.0
>User-Agent: Telnet [ja] (Linux)
>Host: www.yahoo.co.jp
>
>
@ideodora
ideodora / gist:df7b8421d54caad29db3
Created October 9, 2014 05:04
Git 一括rm git status を利用
#git version 1.7.10.1
git status | grep -e deleted | sed -e "s/# deleted: //g" | xargs git rm
@ideodora
ideodora / gist:69adfd8e36ecc3079b56
Created October 7, 2014 08:34
WP メインループ内でのページング
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
@ideodora
ideodora / gist:49d3ea790914741d1d22
Created October 7, 2014 08:09
WP 投稿時間と現在の時間比較 UnixTimestamp
$post_time = get_the_time('U');
$today = time();
@ideodora
ideodora / gist:ca2c5c55ed8d2fe028f0
Created October 7, 2014 07:23
WP WP_Query内でのページング
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
) );
?>
@ideodora
ideodora / gist:d8b5c9dbd6907a1c09ec
Created October 7, 2014 02:44
WP thumbnail サムネイル
add_theme_support( 'post-thumbnails' );
add_image_size('post-index', 300, 9999);