Skip to content

Instantly share code, notes, and snippets.

View oieioi's full-sized avatar
๐Ÿ™
๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™

oieioi

๐Ÿ™
๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™๐Ÿ™
View GitHub Profile
module.exports = buddy = (ary) ->
result = []
while ary.length
left = ary.shift()
right = ary.shift()
obj = {}
obj[left] = right
result.push obj
result
@oieioi
oieioi / remote-branch-delete.sh
Last active August 29, 2015 14:02
ใƒžใƒผใ‚ธๆธˆใฟใƒ–ใƒฉใƒณใƒใ‚’ไธ€ๆฐ—ใซๆถˆใ™
git branch --remote --merged | cut -d"/" -f 2 | grep feature | xargs -Iarg git push origin :arg
@oieioi
oieioi / sort.coffee
Created June 11, 2014 09:41
ใ‚ฏใ‚คใƒƒใ‚ฏใ‚ฝใƒผใƒˆใจใƒใƒ–ใƒซใ‚ฝใƒผใƒˆใฎๆฏ”่ผƒ
# ใ‚ฏใ‚คใƒƒใ‚ฏ
qSort = (ary) ->
if ary.length <= 1
return ary
center = Math.floor (ary.length / 2)
pivot = ary[center]
left = []
right = []
for val in ary
if val < pivot
@oieioi
oieioi / get-random-str.js
Last active August 29, 2015 14:02
ใƒฉใƒณใƒ€ใƒ ใชๆ•ฐๅญ—ๆ–‡ๅญ—ๅˆ—ใ‚’่ฟ”ใ™
var getRandomStr = function(l){var re = "";for(var i = 0;i < l;i++)re+=Math.floor(Math.random()*10);return re;};
@oieioi
oieioi / backbone-async-series.coffee
Last active August 29, 2015 14:02
Backbone.Modelใง้žๅŒๆœŸใง็›ดๅˆ—ใƒชใ‚ฏใ‚จใ‚นใƒˆใ•ใ›ใŸใ„
class AsyncSeriesModel extends Backbone.Model
# ้žๅŒๆœŸใง็›ดๅˆ—ใƒชใ‚ฏใ‚จใ‚นใƒˆใ™ใ‚‹
lastRequest = new $.Deferred().resolve()
sync: ->
argRaw = arguments
# ๅ‘ผใณๅ‡บใ—ๅ…ƒใซ่ฟ”ๅดใ™ใ‚‹deferredใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆ
dfd = new $.Deferred
# ๅ‰ๅ›žใƒชใ‚ฏใ‚จใ‚นใƒˆๅˆ†ใŒ่งฃๆฑบใ™ใ‚‹ใฎใ‚’ๅพ…ใค
# try-catch ใฏๅ€คใ‚’ใ‹ใˆใ™
res = try
sippaisisou()
catch e
{}
# ้–ขๆ•ฐใซ่ค‡ๆ•ฐใฎ้–ขๆ•ฐใ‚’ๆธกใ™
asyncHoge(
->
alert 0
@oieioi
oieioi / gen-coffee-specs.sh
Created October 5, 2014 18:29
CoffeeScript ใฎ class ๅใ‹ใ‚‰ mocha ใƒ†ใ‚นใƒˆใ‚’็”Ÿๆˆใ™ใ‚‹
#!/bin/sh
DIR=~/repos/hogehoge/
match=' class .+extends'
for filepath in `git grep -l -E "$match"`
do
classname_raw=`grep -o -E "$match" $filepath`
classname=`echo $classname_raw| cut -d' ' -f2`
@oieioi
oieioi / app.coffee
Last active August 29, 2015 14:07
localhost ใฏใฆใƒ–ๆ•ฐ
#!/usr/bin/env coffee --nodejs --harmony
request = require 'request'
fs = require 'fs'
# mock request
#request = (str, cb)->
# setTimeout ->
# cb null, null, "{\"hoge\": \"#{str}\"}"
# , 10
@oieioi
oieioi / top30
Last active March 21, 2019 09:54
localhost ใฏใฆใƒ–ๆ•ฐ top30
399 http://localhost:80
146 http://localhost:3000
87 http://localhost:8080
32 http://localhost:8000
27 http://localhost:631
25 http://localhost:5000
24 http://localhost:8888
23 http://localhost:4567
13 http://localhost:4000
12 http://localhost:9292
@oieioi
oieioi / 17-163108.coffee
Last active August 29, 2015 14:07
Convert Backbone.Collection to CSV String
class ConvertCSV extends Backbone.Collection
makeCSVStr: (headers) ->
body = @map (model) ->
headers.map((header)->
'"' + "#{model.get(header)}".replace(/"/g, '""') + '"').join ","
[headers.map((header)-> "\"#{header}\"").join ','].concat(body).join('\n')
con = new ConvertCSV [
{hoge: "\"", fuga: 4, bar: 0}