Skip to content

Instantly share code, notes, and snippets.

View yukikaoru's full-sized avatar

YUKI Kaoru yukikaoru

  • Tokyo/Japan
  • 17:29 (UTC +09:00)
View GitHub Profile
# vim:set encoding=utf-8:
# by ruby1.9.1-p378
require "dbi"
require "kconv"
DBI.connect("DBI:ODBC:foobar", "sa", "sa") do |dbh|
q = "select * from foo_table"
dbh.select_all(q) do |row|
row[0] = NKF.nkf("-wZ1", row[1]).strip
# coding: utf-8
#
#= ついったーとmixiボイスを同期する
#
require "rubygems"
require "mechanize"
require "rubytter"
# mixiのログイン情報
mixi_id = 'mixi_id'
#!/usr/bin/env ruby
data = STDIN.read
ident = `git log -1 --pretty=format:"%h %cd %cn"`
puts data.gsub /\$Id(:?|:.*)\$/, "$Id: #{ident.to_s} $"
@yukikaoru
yukikaoru / doctrine_migration.patch
Created February 21, 2011 12:40
Adapt to multiple connection to Doctrine_Migration.
--- a/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Migration.php
+++ b/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Migration.php
@@ -225,10 +225,16 @@ class Doctrine_Migration
*/
public function setCurrentVersion($number)
{
- if ($this->hasMigrated()) {
- $this->_connection->exec("UPDATE " . $this->_migrationTableName . " SET version = $number");
- } else {
- $this->_connection->exec("INSERT INTO " . $this->_migrationTableName . " (version) VALUES ($number)");
@yukikaoru
yukikaoru / httpdavgmem
Created March 22, 2011 13:51
httpdの1プロセスあたりの最大使用メモリの取得
#!/bin/sh
pnums=`pgrep httpd | wc -l`
sum=`for p in \`pgrep httpd\`; do grep 'VmHWM' /proc/\$p/status; done | sort | awk '{sum = sum + \$2}END{print sum}'`
echo $(($sum / $pnums))
@yukikaoru
yukikaoru / composer.json
Created October 30, 2012 03:57
Symfony2.1の安定板に固定するComposerの設定
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": ">=2.1.0,<2.1.x-dev",
"doctrine/orm": ">=2.3.0,<2.3.x-dev",
@yukikaoru
yukikaoru / router.php
Created October 30, 2012 09:31
PHP built-in web server's routing settings for Symfony2
<?php
/**
* This script set in your project's web/ directory.
* Then, you boot built-in web server as below.
*
* php -S 0.0.0.0:50000 -t /path/to/web/ /path/to/web/router.php
*/
if (preg_match('/^(app|app_dev|config)\.php|\.(js|css|html|gif|png|jpg)$/', $_SERVER['REQUEST_URI'])) {
return false;
} else {
@yukikaoru
yukikaoru / Dispatcher.php
Created July 17, 2013 16:45
Dispatcher to use Ray.Di in CakePHP
<?php
namespace RayDiOnCake\Routing;
use Doctrine\Common\Cache\Cache;
use Ray\Di\Injector;
\App::uses('ClassRegistry', 'Utility');
\App::uses('Dispatcher', 'Routing');
class Dispatcher extends \Dispatcher
@yukikaoru
yukikaoru / index.php
Last active December 19, 2015 21:48
Editing point of webroot/index.php to use Ray.Di in CakePHP
<?php
$Dispatcher = new RayDiOnCake\Routing\Dispatcher();
$cache = new ApcCache();
$cache->setNamespace('ray/di');
$Dispatcher->setInjectorCache($cache);
@yukikaoru
yukikaoru / AppController.php
Created July 17, 2013 16:50
AppController to use Ray.Di in CakePHP
<?php
use Ray\Di\Injector;
App::uses('Controller', 'Controller');
/**
* Application Controller
*
* Add your application-wide methods in the class below, your controllers
* will inherit them.