Skip to content

Instantly share code, notes, and snippets.

View toshimaru's full-sized avatar

Toshimaru toshimaru

View GitHub Profile

##人への関心:誰と、どのくらいの時間会っているかを把握しているか?

  • 情報はいうまでもなく、金もまた人についてくることを知っている。

  • 大切な人に会うための時間は、ほかの予定を変えてでも捻出する。

  • 待ち合わせの場所には、常に約束の時間より余裕をもって到着する。

  • 勉強会や交流会への参加は、会の内容より、参加者の顔ぶれで決める。

desc 'Check links for site already running on localhost:4000'
task :check_links do
begin
require 'anemone'
root = 'http://localhost:4000/'
Anemone.crawl(root, :discard_page_bodies => true) do |anemone|
anemone.after_crawl do |pagestore|
broken_links = Hash.new { |h, k| h[k] = [] }
pagestore.each_value do |page|
if page.code != 200
@toshimaru
toshimaru / dgsync.bat
Created April 18, 2013 18:37
[Windows] sync amazon S3 with DragonDisk Command line sync tool. http://www.dragondisk.com/download-amazon-s3-client-google-cloud-storage-client.html
SET DGTOOLS_ACCESS_KEY=XXXXXXXXXXXXX
SET DGTOOLS_SECRET_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXX
dgsync -v --ssl --dont-delete --endpoint "s3-ap-northeast-1.amazonaws.com" "C:\Users\toshi\picture" "s3://your-s3-bucket/picture"

Usage

 $('#id').trace()

.find('.class').trace();

#/bin/sh
for file in `ls | egrep '[0-9A-z、-◯ぁ-んァ-ヶ亜-腕弌-熙]'`; do
rename_file=`echo ${file} | sed -e 's/[0-9A-z、-◯ぁ-んァ-ヶ亜-腕弌-熙]//g'`
mv $file $rename_file
done
@toshimaru
toshimaru / ForceProperty.php
Last active December 12, 2015 05:28
Normaly, PHP Object can have property freely. But I want to force Object to have the property. This implementation make it possible.
<?php
class ForceProperty {
private $val;
public function __get($name) {
if (property_exists($this, $name)) {
return $this->$name;
} else {
throw new LogicException(sprintf('Undefined property: $%s', $name));
<?php
// add exception_handle
function exception_handler($exception) {
echo "Uncaught exception: file:{$exception->getFile()} line:{$exception->getLine()} {$exception->getMessage()}", "\n";
}
set_exception_handler('exception_handler');
#!/bin/sh
PS3="Which host? > "
select host in `cat ~/.ssh/config | egrep '^Host' | cut -d ' ' -f 2`; do
[[ $host ]] && {
echo "ssh connect to $host"
ssh $host
break;
}
done
@toshimaru
toshimaru / .bashrc
Last active December 10, 2015 23:08 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/<\1$(parse_git_dirty)>/"
@toshimaru
toshimaru / select.php
Last active December 10, 2015 05:48
compare select query (mysql).
these queries are same run time.