Skip to content

Instantly share code, notes, and snippets.

View koriym's full-sized avatar

Akihito Koriyama koriym

View GitHub Profile
@koriym
koriym / gist:2307109
Created April 5, 2012 01:10
PSR-1 formart.
Converted about PHP files from dos format to unix format:
for file in $(find . -name *.php); do dos2unix $file; done;
Expanded all multi-line use statements.
for file in $(find . -name "*.php"); do php -r 'file_put_contents($argv[1],preg_replace_callback("(use (\s*[a-zA-Z0-9\\\\]+(\s*as[\sa-zA-Z0-9]+)?[,;])+)",function($m){return preg_replace("(,\s*([^,;]+))",";\nuse \\1",$m[0]);},file_get_contents($argv[1])));' $file; done;
Removed all trailing whitespaces.
@koriym
koriym / php5.4forUbuntu11_12
Created July 8, 2012 02:26
Install PHP5.4 on Ubuntu 11.10 12.04
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get install php5
@koriym
koriym / gist:3095324
Created July 12, 2012 02:37
@PostConstruct initialize dependency.
/**
* @Inject
*/
public function __construct(HttpRequest $request)
{
$this->request = request;
}
/**
* @PostConstruct
@koriym
koriym / gist:3114137
Created July 15, 2012 00:45
OSX DMG MySql my.cnf
sudo cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf
@koriym
koriym / gist:3116687
Created July 15, 2012 12:53
/etc/apache2/extra/httpd-vhosts.conf
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
@koriym
koriym / gist:3117694
Created July 15, 2012 16:39
Eclipse clean start
/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse -initialize
/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse -clean &
@koriym
koriym / zen-style-session.php
Created July 18, 2012 03:27
Sunday的セッション素案
/**
* @Inject
*/
public function setSession(Session $session)
{
$this->session = $session
}
@Injectで受け取るこのコードはtraitにする。
利用コードはこのように
@koriym
koriym / gist:3272029
Created August 6, 2012 07:48
PHPカンファレンス講演タイトル素案
1) AI programing in PHP
IDS/BFS/IDDFS/A*(A star)等AI探索プログラムの基礎をPHP組み込みのDLL(双方向リンクスト)クラスを使った例で紹介します。
PHPは競技プログラミングに最高最適の言語ではないかもしれませんが十分に楽しめます。
2) パフォーマンス指向アーキテクチャ
パフォーマスは機会であり、コストであり、またユーザー体験です。
Webアプリケーションのパフォーマンス改善を実装レベルではなく、アプリケーションアーキテクチャレベルでPHP/HTTP双方を対象に考察します。
@koriym
koriym / gist:3616424
Created September 4, 2012 04:06
isAssoc($array)
/**
* Determines if an array is associative
*
* @param array $array Array to check
*
* @return bool
*/
private function isAssoc(array $array)
{
return (bool) count(array_filter(array_keys($array), 'is_string'));
@koriym
koriym / gist:3766081
Created September 22, 2012 12:45
[eclipse][juno] Enable to toggle comment with shortcut key [cmd + /]
drop this file onto dropins folder.
http://www.eclipse.org/downloads/download.php?file=/tools/pdt/updates/2.2/milestones/plugins/org.eclipse.php.ui_2.2.1.v20101001-2300.jar
restart eclipse option with -clean
that's it.