Skip to content

Instantly share code, notes, and snippets.

View shoyan's full-sized avatar

Shohei Yamasaki shoyan

View GitHub Profile
@shoyan
shoyan / call_count.php
Created August 20, 2013 04:55
メソッドの呼び出し回数を数えるサンプル
<?php
class CallCount
{
public $call_counts = array();
function counts($method) {
if(!isset($this->call_counts[$method])) {
$this->call_counts[$method] = 0;
}
@shoyan
shoyan / DomSpec.js
Created July 22, 2013 07:25
jasmineのDOM操作のサンプル
describe("DOM操作", function() {
beforeEach(function() {
testDiv = document.createElement('div');
testDiv.innerHTML = '<div id="test-node">test</div>';
document.body.appendChild(testDiv);
@shoyan
shoyan / mock_simple_test_1.0.1.php
Last active December 19, 2015 23:28
SimpleTestのMockを使ったテストのサンプル。 1.0.1はマニュアルのやり方とは違う(function returnsが定義されていない)のでこういう風にやらないといけない。
<?php
/*
* SimpleTestのmockサンプル
* SimpleTest version 1.0.1
*/
@shoyan
shoyan / file1.conf
Created June 6, 2013 12:01
VagrantでCSSの更新が反映されない場合の対処法 ref: http://qiita.com/shoyan/items/12389d5beaa8695b1a53
sendfile off;
@shoyan
shoyan / file0.rb
Created May 30, 2013 11:12
WebDriverを使ってtarget=_blankで開いた別ウインドウにフォーカスする ref: http://qiita.com/items/21f581bbe3c8f00bb566
new_window = page.driver.browser.window_handles.last
page.within_window new_window do
# code
end
@shoyan
shoyan / .bashrc
Created May 21, 2013 06:06
その日の成果をコミットログとして取得する ref: http://qiita.com/items/4f355fa2482b6354de8d
function seika {
local URL="$(git remote -v | head -n 1 | sed -e 's|.*git@\(.*\):\(.*\)\.git.*|https://\1/\2|g')"; git log --pretty="%s \n $URL/commit/%H" --author="$(git config --get user.name)" --since=1.days | sed 's/\\n/\
/g'
}
@shoyan
shoyan / render.branch.local
Created May 2, 2013 08:45
ローカルブランチのディスクリプションと編集者を表示(最後のやつのみ)
git branch | sed 's/^*/ /g' | while read LINE; do echo ${LINE}; git show -s --pretty="%s %an" ${LINE}; echo ''; done; unset LINE
@shoyan
shoyan / today.commit
Last active December 16, 2015 21:39
今日のコミットを取得するやつ
REPO="$(git remote -v | grep 'fetch' | sed 's/origin.*://g' | sed 's/.git (fetch)//g')"; git log --pretty="%s \n https://github.com/$REPO/commit/%H" --author="Shohei Yamasaki" --since=1.days | sed 's/\\n/\
/g'; unset REPO
@shoyan
shoyan / smbclient.sh
Created April 23, 2013 00:39
smbclientのサンプル
smbclient //example.com/shared -c "cd /var/www; put /tmp/hoge.txt hoge.txt" -U username 'passwd'
@shoyan
shoyan / current_branch_push.sh
Created April 19, 2013 06:27
Gitのカレントブランチをリモートにpushするサンプル
git push origin $(git branch | grep -e '^*' | sed "s/^*//g")