Skip to content

Instantly share code, notes, and snippets.

<?php
class FizzBuzz {
public function converts($numbers)
{
$self = $this;
return __::map($numbers, function($n) use($self) {
return $self->convert($n);
});
}

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

@haru01
haru01 / gist:6097521
Last active December 20, 2015 07:59
ローマ数字の素振り途中
class RomanNumber < Struct.new(:to_s, :to_i)
# TODO 1-3999まで
def self.initWithInt(int)
str = to_roman_str(int)
RomanNumber.new(str, int)
end
def self.initWithStr(str)
int = to_roman_int(str)

take2 は https://github.com/haru01/log/blob/master/pattern_sheed.md

TDD実践・学習パターン

TDDを 初心者が熟練者になって、現場で実践していくコツを書いていきます。 すべて実施する必要はありません。上から順に実施する必要もありません。 現状の診断や、自分の状況に合いそうなものを複数ピックアップして、 ベイビーステップで個人やチームの学習と成長の物語を描く道具として使われることを想定しています。

まだ未完です。ガンガン変わっていきます。 :p

テスティングフレームワークのインストール

TDDを試せる環境を用意する。これがなきゃ始まらない。

テストの道具を揃える

保存したら即実行、前提データの準備、UIの実行、時間をコントロールするライブラリー、モックライブラリー、Given, When, Thenのフレームワークなど道具を揃え、 すぐに書けるように準備する。

Red Green Refactor のリズム

簡単なお題でRed Green Refactorを試して、体で体感する。

@haru01
haru01 / gitconfig_alias
Created June 11, 2014 00:22
gitconfig_alias
[alias]
co = checkout
st = status -s
pr = pull --rebase
c = commit
a = add
al = add -A .
au = add -u
ap = add -p
b = branch
@haru01
haru01 / gist:06c6b53a279f0d6ce9ed
Last active August 29, 2015 14:19
Event 中心に
// 学習用
// * See Also http://ookami86.github.io/event-sourcing-in-practice/#how-eventsourcing-works/04-restoring-objects-5.md
// * http://martinfowler.com/eaaDev/EventSourcing.html
//
function BanckingAccount(id, owner, balance, version) {
this.id = id || 0;
this.owner = owner || "";
this.balance = balance || 0;
this.version = version || 0;
}
'use strict';
var fetch = require('node-fetch');
var assert = require('power-assert');
function fetchPost() {
return fetch("http://jsonplaceholder.typicode.com/posts/1")
.then(function(res) {
return res.json();
}).catch(function(e) {
require 'natto'
word_counters = {}
nm = Natto::MeCab.new
Dir::entries(".").select { |f| f.match /^ch.*\.re$/}.each do |file|
File.open(file, "r") do |f|
f.each_line do |line|
nm.parse(line) do |n|
word_counters[n.surface] = word_counters[n.surface] ? word_counters[n.surface] + 1 : 1
@haru01
haru01 / ShowRange.ino
Last active August 10, 2016 21:54
ultrasonic で距離を測定し rgb_lcd で表示する
#include "Ultrasonic.h"
#include "rgb_lcd.h"
#include <Wire.h>
rgb_lcd lcd;
Ultrasonic ultrasonic(7);
void setup()
{
lcd.begin(16, 0);