Skip to content

Instantly share code, notes, and snippets.

View co3k's full-sized avatar
🔞
"><s>'\

Kousuke Ebihara co3k

🔞
"><s>'\
View GitHub Profile
Hi,
I've tried to write Doctrine_Query_Tokenizer as PHP extension (This is my first PHP extension):
http://github.com/ebihara/php-dql-tokenizer
My product executes many DQLs (e.g. about 200 queries) in per request. In this case, DB server is not heavy, but I noticed CPU usage of Web server is high. I checked result of XHProf, and this result showed that executing some methods of Doctrine_Query_Tokenizer uses a lot of CPU resources.
So I tried to write this extension for resolving my problem.
Of course my case is a little special. I think that many products don't execute too many DQLs. But I want you to try to use this extension if you are interested. (I have a plan to write many Doctrine features in C, not only tokenizer)
<?php
require_once 'SymfonyComponents/YAML/sfYaml.php';
function output_ticket_title($title)
{
preg_match('/^.+?#(?P<ticket_id>[0-9]+):(?P<ticket_subject>.*)$/', $title, $matches);
$author = '';
$authors = array();
<?php
$pathToNewZend = '/usr/local/lib/php/Zend';
$pathToOldZend = '/home/co3k/www/sf/op3-ebihara/lib/vendor/Zend';
//---
require_once $pathToNewZend.'/Version.php';
$pathToHostNameValidator = '/Validate/Hostname';
/*
INSTALL::
$ apxs2 -c mod_doyagawa.c -ltokyocabinet -ljansson
$ libtool --mode=install cp mod_doyagawa.la $PWD
Restful API Interface::
Get Feed: GET http://example.com/doya
Get Entry: GET http://example.com/doya/{id}
<?php
$user = posix_getpwuid(posix_getuid());
$current_umask = umask(0000);
$dir = '/tmp/'.$user['name'].'-'.date('YmdHis');
@mkdir($dir, 0777, true);
var_dump(substr(sprintf('%o', fileperms($dir)), -4));
<?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
require_once 'config.php';
define('SPREADSHEET_ID', 'tPPseSNcB7ho4tho-2aB4vg');
<?php
/**
* Copyright 2010 Kousuke Ebihara
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@co3k
co3k / openpneActionListTask.class.php
Created October 29, 2010 05:51
symfony アプリケーションのアクションの一覧を出すやつ
<?php
/**
* This file is part of the OpenPNE package.
* (c) OpenPNE Project (http://www.openpne.jp/)
*
* For the full copyright and license information, please view the LICENSE
* file and the NOTICE file that were distributed with this source code.
*/
@co3k
co3k / session_id_length_machine.php
Created November 9, 2010 07:24
ハッシュアルゴリズムと使用する文字のパターンを変えたときに PHP のセッション ID がどれくらいの長さになるかを検証するマシーン
<?php
echo "ハッシュアルゴリズムと使用する文字のパターンを変えたときに PHP のセッション ID がどれくらいの長さになるかを検証するマシーン".PHP_EOL;
$list = hash_algos();
$example = (string)time();
$bits = array(4, 5, 6);
echo "アルゴリズム";
foreach ($bits as $bit)
@co3k
co3k / session_id_length_machine.php
Created November 9, 2010 07:24
ハッシュアルゴリズムと使用する文字のパターンを変えたときに PHP のセッション ID がどれくらいの長さになるかを検証するマシーン
<?php
echo "ハッシュアルゴリズムと使用する文字のパターンを変えたときに PHP のセッション ID がどれくらいの長さになるかを検証するマシーン".PHP_EOL;
$list = hash_algos();
$example = (string)time();
$bits = array(4, 5, 6);
echo "アルゴリズム";
foreach ($bits as $bit)