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 "ใŒใ‚“ใฐใ‚Œ"