Skip to content

Instantly share code, notes, and snippets.

<?php
namespace Acme\DemoBundle\Controller;
use Acme\DemoBundle\Form\Entity\Item;
use Acme\DemoBundle\Form\Entity\Tag;
use Acme\DemoBundle\Form\Type\ItemWithTagsType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@hidenorigoto
hidenorigoto / scalatest.md
Last active August 29, 2015 13:58
ScalaTest

ScalaTestでテストするときのメモ

build.sbt

libraryDependencies ++= Seq(
  "org.scalatest" % "scalatest_2.10" % "2.1.0" % "test",
  "org.scalacheck" %% "scalacheck" % "1.11.3" % "test"
)
@hidenorigoto
hidenorigoto / gist:40c92edb63aae027e739
Created June 16, 2014 07:08
PHPUnitでデータプロバイダを使ったテストのデータごとにメッセージを付ける
<?php
class ATest extends \PHPUnit_Framework_TestCase
{
/**
* @test
* @dataProvider provider
*/
public function テスト($a, $b)
{
$this->assertThat($a == $b, $this->equalTo(true));
@hidenorigoto
hidenorigoto / modukes.py
Created June 21, 2014 17:26
ロードされているモジュールリスト
#!/usr/bin/env python
# -*- coding: utf-8 -*
# from http://tell-k.hatenablog.com/entry/2012/02/04/131805
from pydoc import ModuleScanner
from string import find
modules = []
def callback(path, modname, desc, modules=modules):
<html>
<head>
<link rel="stylesheet" href="joint.css" />
<script src="joint.js"></script>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<body>
<div id="myholder"></div>
<?php
class Lessons
{
public function main($input)
{
$submissions = $this->processInput($input);
$results = $this->mainProcess($submissions);
$output = $this->printResult($results);
/**
* Class AddMultiController
*
* @Route("/bill")
*/
class EditMultiController extends UsecaseController
{
const ROUTE_INPUT = 'xnni_bill_editmulti_input';
const ROUTE_CONFIRMATION = 'xnni_bill_editmulti_confirmation';
const ROUTE_LIST = 'xnni_construction_receipt_check_search';
@hidenorigoto
hidenorigoto / test1.java
Created January 23, 2015 15:51
refactoring sample
if (date.before(SUMMER_START) || date.after(SUMMER_END))
charge = quantity * _winterRate + _winterServiceCharge;
else charge = quantity * _summerRate;
if (notSummer(date))
charge = winterCharge(quantity);
else charge = summerCharge(quantity);
@hidenorigoto
hidenorigoto / 1_Haydnをコレクション演算部分に適用する例.md
Last active August 29, 2015 14:24
Workflow getActivitiLog (一部Haydn利用)

Haydnをコレクション演算部分に適用する例

利用するコード: https://github.com/phpmentors-jp/workflower/blob/master/src/Workflow/Workflow.php#L411

  • ここではコレクションの要素を変換しつつ、変換結果を見てフィルタし、最終オブジェクトへ変換する。HaydnではPHPの配列/連想配列に入っているものなら何でも扱えるので、このようにオブジェクトのコレクションごと変換・フィルタといった操作として記述できる。
@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";