Skip to content

Instantly share code, notes, and snippets.

View Leko's full-sized avatar
🏠
Working from home

Shingo Inoue Leko

🏠
Working from home
View GitHub Profile
@Leko
Leko / underscore.go
Last active October 28, 2015 17:30
interface多すぎ、generics使いたいつらい・・・
func Each(list []interface{}, iteratee func(el interface{}, index int, list *[]interface{})) {
}
func Map(list []interface{}, iteratee func(el interface{}, index int, list *[]interface{}) interface{}) []interface{} {
}
func Reduce(list []interface{}, iteratee func(memo interface{}, value interface{}, index int, list *[]interface{}) interface{}, memo interface{}) interface{} {
@Leko
Leko / beam-search.js
Last active June 5, 2016 18:39
幅優先ビームサーチがこれで合ってるのか分からないけど説明読んだだけのイメージで実装してみた
// 結論(出力結果)
// Rank 1: Sum: 486, HELMS-05(54)
// BODIES-05(50)
// FOLDS-01(141)
// HANDS-04(120)
// LEGS-04(121)
// Rank 2: Sum: 484, HELMS-05(54)
// BODIES-05(50)
// FOLDS-05(139)
// HANDS-04(120)
@Leko
Leko / migrate.md
Created October 7, 2015 14:12
Schemaリベンジ マイグレーション

共通属性

  • required
  • minLength

採用

  • boolean(MySQL:BOOLEAN PostgreSQL:BOOLEAN SQLite3:INTEGER)
  • integer(MySQL:{TINYINT,SMALLINT,INT,MEDIUMINT,BIGINT} PostgreSQL:{SMALLINT,INT,BIGINT} SQLite3:INTEGER)
@Leko
Leko / drrr.php
Created October 3, 2015 19:59
三└(┐卍^o^)卍ドゥルルル
<?php
namespace Drrr;
define('FPS', 15);
define('LINES', 10);
define('WIDTH', (int)`tput cols`);
class Loop {
private $token;
@Leko
Leko / integrity-demo.js
Last active September 5, 2015 17:23
Confine any process into transaction
'use strict';
var Integrity = require('./integrity'),
Transaction = Integrity.Transaction,
Action = Integrity.Action;
function add(target, num) {
return function() { target.num += num; };
}
@Leko
Leko / lifegame.ts
Created July 29, 2015 19:28
Lifegame in Typescript
// How to run
//
// ```sh
// $ npm install -g typescript
// $ tsc index.ts
// $ node index.js
// ```
const enum State {
ALIVE,
@Leko
Leko / newtons-method.go
Created July 18, 2015 22:43
ニュートン法による平方根の近似解析
package main
import (
"math"
"fmt"
)
func Sqrt(x float64) float64 {
z := float64(1)
@Leko
Leko / lifegame.go
Last active August 29, 2015 14:24
LifeGame for Go
// Run: go build /path/to/lifegame/go/index.go; ./index
// Environment variables:
// - LIFEGAME_WIDTH: int(default is terminal width)
// - LIFEGAME_HEIGHT: int(default is terminal height)
package main
import (
"fmt"
"math/rand"

Revelメモ

知らないから不便に感じるのかも?

複数アプリ開発するときに全部GOPATH以下にやらなきゃいけないの?

ディレクトリを散らかすつもりもないしそういうルールなら別に従うのだけど、
revel newでアプリがGOPATH以下に作られたのでそう見えた。

GOPATHの勉強をしてないのでこの辺よくわかっていない

Goのここがイケてない

@Leko
Leko / 0_profilify.js
Last active August 21, 2017 02:45
Any function profiling
function profilify(fn, label) {
var displayName = label || fn.name,
called = 0,
profilified = function() {
var args = [].slice.call(arguments),
startedAt = new Date(),
defaults = { total: 0, times: 0, average: 0 },
ret;
profilify._stats[displayName] = profilify._stats[displayName] || defaults