Skip to content

Instantly share code, notes, and snippets.

@hidenorigoto
hidenorigoto / go-form-sample2.go
Created November 13, 2009 17:39
golang CGI form sample
package main
import(
"io";
"fmt";
"bytes";
"template";
"os";
"strings";
"strconv";
"http";
<?php
/**
* xnTwitterStream.class.php
* Twitter Streaming APIでのデータの取得用クラス
**/
class xnTwitterStrream implements Iterator
{
const READ_NULL_REPEAT_MAX = 30;
/**
* @var $dispather sfEventDispatcher
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php echo $this->esi->handle($this, 'http://ubook/~goto/symfony-sandbox/web/HelloBundle%3ACommon%3Aheader/none.html', '', true)->getContent() ?>
Hello goto!
@hidenorigoto
hidenorigoto / HelloExtension.php
Created February 17, 2011 07:30
enabling Symfony2 DI container in custom class
<?php
// Sensio/HelloBundle/DependencyInjection
namespace Sensio\HelloBundle\DependencyInjection;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
@hidenorigoto
hidenorigoto / gist:960995
Created May 8, 2011 00:45
Request::hasSession()について
  • Request::hasSession()の現在の実装の意図

    1. (意図A)クライアントから送られてきた(本来の意味の)リクエストがセッション有効状態か(=Cookieを持っているか)を調べる
    2. (意図B)単にセッションオブジェクトがあるかないかという判定
    3. (意図C)セッションオブジェクトがあり、開始済みかどうか

    現在のhasSession()メソッドは、意図Aの実装であると考えられる。ただし、以下に挙げる呼び出し箇所では、意図Bなどが混在して用いられていると思われる。

  • Request::hasSession()の使われ方
@hidenorigoto
hidenorigoto / gist:974142
Created May 16, 2011 09:27
sfjp-doc-mainを最新にする
# 多分一度cloneし直したほうが早いので、作業したファイルをどこかにバックアップ
# その後 git://github.com/hidenorigoto/sfjp-doc-main.git を clone
git clone git://github.com/hidenorigoto/sfjp-doc-main.git
# sfjp-doc-mainディレクトリに移動してブランチを作成
git checkout -b translate-awos-228
# バックアップしたファイルを追加して、add → commit
git add .
git commit
@hidenorigoto
hidenorigoto / gist:981969
Created May 19, 2011 22:42 — forked from avalanche123/gist:981817
GitHub Emoji
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@hidenorigoto
hidenorigoto / env.php
Created May 29, 2011 06:04
Install Behat (Symfony SE 2.0.1)
<?php
// for Symfony2 tests
$world->getContainer = function() use ($world) {
return $world->getSession()->getDriver()->getClient()->getKernel()->getContainer();
};
$world->getEm = function() use ($world) {
return $world->getContainer()->get('doctrine')->getEntityManager();
};
@hidenorigoto
hidenorigoto / gist:1130338
Created August 7, 2011 12:36
Query Example (Doctrine2 QueryBuilder)
$qb = $em->createQueryBuilder();
$qb->select('p')
->from('AcmeTestBundle:Post', 'p')
->where('p.order_date < :targetDate')
->setParameters(array(
'targetDate' => new \DateTime('2011-08-07'),
));
$q = $qb->getQuery();
@hidenorigoto
hidenorigoto / gist:1223740
Created September 17, 2011 07:59
Stagehand_TestRunner for Symfony2

Symfony2のプロジェクトをStagehand_TestRunnerで継続テストする

準備

最初にプリロード用スクリプトを用意します。 プリロードスクリプトでは、Symfony2のカーネルディレクトリ(KERNEL_DIR)の設定と、Symfony2のブートストラップファイルの読み込みを行うようにします。 (app/testrunner_preload.phpに作成します)