Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

... .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.html)$ file.php?target=$1 [QSA,L]
#敢えてファイルが存在するときで、末尾に.htmlが付くファイルの場合のみリライトさせる
</IfModule>
@chobie
chobie / gist:733469
Created December 8, 2010 15:58
pecl_inotifyを使ったディレクトリ監視(適当版)
<?php
$fd = inotify_init();
$desc = inotify_add_watch($fd,"directory",IN_CLOSE_WRITE);
chdir(__DIR__);
array_shift($_SERVER["argv"]);
$command = __DIR__ . "/" . join(" ", $_SERVER["argv"]);
while($events = inotify_read($fd))
{
@chobie
chobie / gist:736402
Created December 10, 2010 16:16
Doctrator meets cakephp
#controller/doctrine_controller.php
<?php
class DoctrineController extends AppController{
public $name = "Doctrine";
public function index()
{
//AppModelで登録してあるようなのでひっぱる
$em = $this->Doctrine->doctrineConn;
$article = new Model\Article();
@chobie
chobie / gist:752433
Created December 23, 2010 01:56
my .vimrc
set nocompatible
filetype indent plugin on
syntax on
set number
set hidden
set wildmenu
set showcmd
set hlsearch
set nomodeline
@chobie
chobie / uhi
Created December 25, 2010 03:01
git clone https://github.com/libgit2/libgit2.git libgit2
cd libgit2
./waf configure
./waf build-shared
./waf install-shared
# see also
# http://libgit2.github.com/api.html#index
# libgit2を使ったgitのインデックスファイルの捜査でSegmentation Faultが起きちゃう。
@chobie
chobie / monitor.php
Created January 28, 2011 10:13
inotify & rsync
<?php
/**
svn co http://svn.php.net/repository/inotify/trunk php-inotify
cd php-inotify
phpize && ./configure && make
sudo make install
# add "extension = inotify.so" to your php config.
# and modify this script.
php monitor.php
*/
@chobie
chobie / gist:801723
Created January 29, 2011 10:08
KyotoTycoon PHP Bindingののパフォーマンスチェック
<?php
/**
KyotoTycoon PHP Bindingののパフォーマンスチェック
**/
$count = 1000;
//////////////////////////////////////////////////////////////////////////////////////////////////
printf("[Kyoto\\Tycoon\\HttpClientのテスト]\n");
$client = new Kyoto\Tycoon\HttpClient();
@chobie
chobie / cb.c
Created February 6, 2011 17:14 — forked from rsky/cb.c
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <php.h>
#include <ext/standard/info.h>
#include <Zend/zend_extensions.h>
/*
メモるよ!
#from zend/Zend.h

cat git object.

cat .git/objects/dd/f452dc1825ed7b0dca08b9a322174b3394644d  | php -r 'echo gzuncompress(stream_get_contents(fopen("php://stdin","r")));'
# git リポジトリ内でそれっぽいディレクトリ名に移動する
function j()
{
top_dir=`git rev-parse --show-cdup`
path=`git ls-tree -rd --name-only --full-tree $(git rev-parse HEAD) | grep ${1}$`
result=$?
if [ ${result} -eq 0 ]; then
echo "# jumping to [${path}]";
cd ${top_dir}${path}