Skip to content

Instantly share code, notes, and snippets.

View sotarok's full-sized avatar
🍺
developing Crowi and beer

Sotaro Karasawa sotarok

🍺
developing Crowi and beer
View GitHub Profile
<?php
/**
*
*/
$dt0 = '2010-02-01 00:02:33';
$dt1 = '2011-02-01 00:02:33';
$dt2 = '2012-02-01 00:02:33';
var_dump($dt1 - $dt0); // int(1)
var_dump($dt1 - $dt2); // int(-1)
@sotarok
sotarok / gist:2222814
Created March 28, 2012 01:50
Ethna phpdoc
$ phpdoc -s on -i "$(echo Ethna-2.6.0beta2011102522/test/**/*(:t) Ethna-2.6.0beta2011102522/skel/**/*(:t) | tr ' ' ',' )" -t doc -d Ethna-2.6.0beta2011102522 -o HTML:frames:earthli.utf8 -ti Ethna
@sotarok
sotarok / BehatTest.php
Created February 19, 2012 19:00
Running Behat in the Test Case of PHPUnit on Non-Symfony Application.
<?php
/**
*
* @forked https://gist.github.com/1298503
*/
require_once 'behat/autoload.php';
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
{#
# ref: PaginatorBudnel:Pagination:sliding.html.twig
# with twitter bootstrap
#}
{% if pageCount > 1 %}
<div class="pagination">
<ul>
{% if first is defined and current != first %}
@sotarok
sotarok / file0.php
Created January 4, 2012 10:19
タイムゾーンを考慮した date time string <-> unix timestamp 相互変換 ref: http://qiita.com/items/1561
<?php
/**
* Usage:
*
* $ php t.php 1324393200
* => 2011-12-20 15:00:00
* $ php t.php 1324393200 'Asia/Tokyo'
* => 2011-12-21 00:00:00
* $ php t.php '2011-12-21 00:00:00'
* => 1324393200
@sotarok
sotarok / growl_restart
Created December 6, 2011 07:23
Mac OS X で Growl が暴走したときに再起動 ref: http://qiita.com/items/1302
#!/bin/bash
PID=$(ps ax | grep Growl.app | grep -v grep | awk '{print $1};')
test -z "$PID" && open -j -a Growl && echo "Growl restarted on $(date) :: pid not found ($PID)" >> /tmp/growl_restart.log && exit
CPU_USAGE=$(top -pid $PID -l 2 -s 5 -stats cpu | tail -n1 | cut -d"." -f1)
if test $CPU_USAGE -gt 80
then
killall Growl
open -j -a Growl
--enable-fpm --with-regex=php --disable-rpath --disable-static --with-pic --with-layout=GNU --enable-calendar --enable-fileinfo --enable-hash --enable-json --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-bcmath --with-bz2 --enable-ctype --with-iconv --enable-exif --enable-ftp --with-gettext --enable-mbstring --with-onig=/usr --with-pcre-regex --with-mysql=shared,/usr --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-mysqli=shared,/usr/bin/mysql_config --enable-pdo=shared --with-pdo-mysql=shared,/usr --with-pdo-pgsql=shared,/usr/bin/pg_config --with-pdo-sqlite=shared,/usr --with-pdo-dblib=shared,/usr --enable-phar --enable-shmop --enable-sockets --enable-simplexml --enable-dom --enable-wddx --with-libxml-dir=/usr --enable-tokenizer --with-zlib --with-kerberos=/usr --with-openssl=/usr --enable-soap --enable-zip --with-mhash=yes --without-mm --with-curl=shared,/usr --with-enchant=shared,/usr --with-zlib-dir=/usr --with-gd=shared --enable-gd-native-ttf --with-gmp=shared,/usr --with-jpeg-dir=shared,
@sotarok
sotarok / 999-crocos-disable-constructor-check
Created September 4, 2011 16:11
Degraded https://bugs.php.net/bug.php?id=54384 but enable extend SPL internal classes.
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -889,10 +889,12 @@ static void construction_wrapper(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
}
goto cleanup;
}
+ /*
if (!EG(exception) && SPL_G(validating_fun)(object_data TSRMLS_CC) == 0)
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC,
"In the constructor of %s, parent::__construct() must be called "
@sotarok
sotarok / servers.rb
Created August 24, 2011 02:18
inherit previous roles of a task for capistrano server selection.
# based on: http://pastie.org/293845
module Capistrano
class Configuration
module Servers
alias_method :original_find_servers, :find_servers
def find_servers(options={})
servers = original_find_servers options
stack_roles = task_call_frames.collect {|frame| frame.task.options[:roles]}.compact.flatten
diff --git a/src/Git/Daily/Command/Release.php b/src/Git/Daily/Command/Release.php
index 0f9cf47..de7e070 100644
--- a/src/Git/Daily/Command/Release.php
+++ b/src/Git/Daily/Command/Release.php
@@ -539,9 +539,9 @@ class Git_Daily_Command_Release
self::outLn("Author list:");
foreach ($author_list as $author => $id_list) {
- self::outLn("= $author");
+ self::outLn("\t$author:");