Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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: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))
{
... .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.html)$ file.php?target=$1 [QSA,L]
#敢えてファイルが存在するときで、末尾に.htmlが付くファイルの場合のみリライトさせる
</IfModule>
//今見ているページのURLを含んだツイートがあれば表示する
//from http://blog.asial.co.jp/659
function myfunc(json) {
var box = $('body');
$(json.results).each(function(i, v) {
v.jp_created_at = dateJp(v.created_at);
var html = template('<div class="twit">\
<blockquote class="commentOne">\
<p class="commentText">#{text}</p><p class="twitDate">#{jp_created_at}<\/p>\
<span class="arrow" \/>\
@chobie
chobie / gist:627733
Created October 15, 2010 06:44
Doctrine2とmysqliでのインサートの比較用
<?php
// 本番環境ではやらないでね!
$mysqli = mysqli_init();
$mysqli->real_connect("localhost","user_name","password","db_name");
if($error = mysqli_connect_error()){
throw new RuntimeException($error);
}
$mysqli->set_charset("utf8");