Skip to content

Instantly share code, notes, and snippets.

View oieioi's full-sized avatar
🐙
🐙🐙🐙🐙🐙🐙🐙🐙🐙

oieioi

🐙
🐙🐙🐙🐙🐙🐙🐙🐙🐙
View GitHub Profile
class window.Fibonacci
# 初期条件
fibAry : [0,1]
# フィボナッチ数を返す
getFib : (n) =>
return @fibAry[n] if @fibAry[n]?
ret = (@getFib n - 1) + (@getFib n - 2)
@fibAry[n] = ret
@oieioi
oieioi / fib-uzu.coffee
Created June 26, 2013 01:59
draw fibonacci gurugurus
###
フィボナッチ渦巻きを書く
###
class window.FibUzumaki extends window.Fibonacci
###*
* コンストラクタ
* @param {object} ctx キャンバスコンテキスト
###
constructor: (@ctx) ->
super()
@oieioi
oieioi / string-shuffle.js
Last active December 19, 2015 04:29
String shuffle and random and
// 文字列シャッフル
String.prototype.shuffle = function() {
var result = [];
var ary = this.split("");
var l = ary.length;
for (var i = 0;i < l;i++) {
var random = Math.floor(Math.random()*ary.length);
result.push(ary[random]);
ary.splice(random,1);
}

Ré:A メモ

  • メンバーが統一感ある。編集後記の

ひとりひとりの「夢」が、この小さな雑誌のなかで、なにか関係し合えたらとおもう。

ってのが良かった。壮大な感じがする。孤独感とその逆に安心感がある

  • ビニール傘の表現が良い
  • みんな凝った言い方してる。
_ = require "underscore"
# recursive trim
trimAll = (obj, {trimType} = {})->
trimFunc = switch trimType
when "r" then "trimRight"
when "l" then "trimLeft"
else "trim"
@oieioi
oieioi / get-insertion.sh
Last active January 4, 2016 02:29
git でauthor別の差し引き,追加行,削除行を取得する
git log origin/master --since=2014-01-01 --pretty='format:%an' --no-merges --shortstat | awk -F ',' '/^[^ ]/ {name = $1}/^ /{split($2, data, " ");ary[name] += data[1];split($3, data, " ");arydel[name] += data[1]}END{ for (name in ary){ print ary[name] - arydel[name] " line : " name " added " ary[name] " lines, deleted " arydel[name] " lines"}}'|sort -n
@oieioi
oieioi / prime.coffee
Last active August 29, 2015 14:01
prime?
isPrime = (num)->
# 整数チェック
if Math.floor(num) isnt num then return false
if num < 2 then return false
if num is 2 then return true
# 偶数は除いてチェック
if num % 2 is 0 then return false
for n in [3..Math.floor num/2] by 2 when num % n is 0 then return false
# 素数発見
@oieioi
oieioi / ticket.coffee
Last active August 29, 2015 14:01
CodeIQチケットゴブル問題写経 https://gist.github.com/hyuki0000/6273a52b9454ccfca095
#!/usr/bin/env coffee
fs = require 'fs'
_ = require 'lodash'
class Ticket
constructor: (@country, fromMonth, fromDay, toMonth, toDay) ->
if fromMonth > toMonth
throw "invalid"
else if fromMonth is toMonth and fromDay >= toDay
@oieioi
oieioi / 500yen.coffee
Last active August 29, 2015 14:01
給料を500円玉の重さにして返す
#!/usr/bin/env coffee
argv = require 'argv'
getSalaryMass = (salary, {mass, coin} = {})->
mass = mass or 7
coin = coin or 500
"#{(salary / coin) * mass}"
argv.option [
@oieioi
oieioi / shinitai.coffee
Created May 28, 2014 09:26
しにたい
#!/usr/bin/env coffee
if (Math.floor Math.random()*100) > 98
console.log "シネ"
else
console.log "がんばれ"