Skip to content

Instantly share code, notes, and snippets.

@a-suenami
a-suenami / Hello, World.
Created February 23, 2012 02:33
"Hello, World" with Lua.
print("hello, world!")
@a-suenami
a-suenami / sort.lua
Created February 23, 2012 02:49
sorting program with Lua.
data = {2, 32, 12, 0, 493, 4, 5, 32}
for i = 1, #data do
for j = i + 1, #data do
if data[i] >= data[j] then
tmp = data[i]
data[i] = data[j]
data[j] = tmp
end
end
end
@a-suenami
a-suenami / sha1.sh
Created March 3, 2012 10:43
create sha1 hash.
#!/bin/sh
echo $1 | openssl dgst -sha1
@a-suenami
a-suenami / Ethna_DB_Mock.php
Created August 15, 2012 08:02
Ethna_DB_Mock
<?php
function setUp()
{
$this->manager = $this->backend->getManager($this->manager_name);
// DBをモックに差し替え
require_once 'Ethna/test/DB/Ethna_DB_PDO_Test.php';
$db = $this->manager->db;
$this->manager->db = new Ethna_DB_PDO_Mock($this->ctl, $db->getDSN(), $db->persistent);
@a-suenami
a-suenami / README.md
Created November 8, 2012 04:56
git-branch-log.sh

使い方

任意のディレクトリにダウンロードして、以下のコマンドを実行する。

./git-branch-log.sh <merge_commit>
@a-suenami
a-suenami / ajax_sample.coffee
Created November 28, 2012 08:27 — forked from skyriser/ajax_sample.coffee
jQuery Deferredの簡単な使い方
# 複数のAjax通信を行って全ての結果がそろったら次の処理を実行したい等の場合
# Ajax処理
somethingAjax1: ->
dfd = $.Deferred()
$.getJSON '/something.json', {'param': param }, (data) =>
# dataを使った処理をする
# 無事完了したらresolve()
dfd.resolve()
@a-suenami
a-suenami / Status.php
Last active December 10, 2015 08:58
ENUM値をオブジェクトにしたい。
<?php
class Status
{
private $value;
private static $instances = array();
private function __construct($value)
{
@a-suenami
a-suenami / AbstractEntity.php
Last active December 15, 2015 08:29
PHPでDDD(ドメイン駆動設計)やるにはどうすればいいのか考え中。
<?php
class AbstractEntity implements EntityInterface
{
}
@a-suenami
a-suenami / fib.scala
Created March 27, 2013 04:02
scalaでフィボナッチ数列。
object Fib extends App {
def fib(n: Int): Int = {
if (n < 2) { return n } else { return fib(n-1) + fib(n-2) }
}
Console.println("fib(1) = " + fib(1));
Console.println("fib(2) = " + fib(2));
Console.println("fib(3) = " + fib(3));
Console.println("fib(4) = " + fib(4));
Console.println("fib(5) = " + fib(5));
Console.println("fib(6) = " + fib(6));
@a-suenami
a-suenami / pre-commit.sh
Created April 8, 2013 05:59
特定ディレクトリ以下の変更があった際にアラートを出すコミット前フック。
#!/bin/sh
files=`git diff --cached --name-only`
assets_path=`git config assets.path`
[ -z "$assets_path" ] && exit 0
for file in $files
do
if [[ "$file" =~ "^$assets_path" ]]; then