Skip to content

Instantly share code, notes, and snippets.

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

oieioi

🐙
🐙🐙🐙🐙🐙🐙🐙🐙🐙
View GitHub Profile
@oieioi
oieioi / test.coffee
Last active August 29, 2015 14:08
mocha `before` and `beforeEach`
###
$mocha test.coffee --compilers coffee:coffee-script/register --reporter=spec --timeout=20000
outside
before
before done
beforeeach
beforeeach done
out it
✓ out it
@oieioi
oieioi / lists.js
Last active August 29, 2015 14:13
convert html list to markdown list
(function(ul, filter){
var getGeneration = function(li){
var f = function(li, count){
var parent = li.parentNode;
if (parent.nodeName !== 'UL'){
return count - 1;
}
return f(parent.parentNode, ++count);
}
@oieioi
oieioi / csv.js
Created April 14, 2015 01:50
parse csv to JSON
// parseCsv('f1,2\nf2,3\nf3,4\n', ['name', 'value'])
// => [{"name":"f1", "value":"2"}, {"name":"f2", "value":"3"}, {"name":"f3", "value":"4"} ]
export default function parseCsv(str, header){
var lines = str.split('\n');
return lines.map((ln) => {
var items = ln.split(',');
var ob = {};
header.forEach((it, count)=>ob[it] = items[count]);
return ob;
});
@oieioi
oieioi / 5-programming-problem
Last active August 29, 2015 14:20
5-programming-problems
http://www.softantenna.com/wp/software/5-programming-problems/
https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
@oieioi
oieioi / gist:f53793b144bdfbb2bfc9
Last active May 12, 2017 07:02
http://postd.cc の記事のおしゃれなバックグラウンドが邪魔なので消す
// ==UserScript==
// @name POSTDを軽くする
// @namespace http://your.homepage/
// @version 0.1
// @description enter something useful
// @author You
// @match http://postd.cc/**
// @grant none
// ==/UserScript==
@oieioi
oieioi / arrow-function.js
Last active August 29, 2015 14:23
tower-of-babel
'use strict';
// 変数 a はblockスコープの中でも外でも再代入可能な有効な変数です。変数宣言の方法(var|let|const)のいずれを利用するべきか検討してください
var a = 5;
// 変数 b は再代入不可能な変数です。変数宣言の方法(var|let|const)のいずれを利用するべきか検討してください
const b = process.argv[2];
if (a === 5) {
// ここでの変数 c は再代入可能ですが、このblockの中でだけ有効な変数です。変数宣言の方法(var|let|const)のいずれを利用するべきか検討してください。
let c = 4;
@oieioi
oieioi / callee.js
Created June 26, 2015 06:45
event call
var EventEmitter = require('events').EventEmitter;
var inherits = require('util').inherits;
var Callee = function(){};
inherits(Callee, EventEmitter);
var o = new Callee();
o.on('first', function(){
console.log('first');
#raw_list = STDIN.gets.chomp.split("\n").collect {|item| item.to_i}
raw_list = []
while str = STDIN.gets#.chomp
break if str.empty?
raw_list.push str.to_i
end
count_changed = 0
raw_list.each_with_index do |item, index|
if item != (index + 1) then
inputs = []
while str = STDIN.gets.chomp
break if str.empty?
inputs.push str.split(',').collect {|i|i.to_i}
end
class Amida
def initialize (yokobous)
@yokobous = yokobous.clone
@amida_length = @yokobous[0].length + 1