This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[1,2,3],[4,5,6],[7,8,9]].reduce((p, v) => { return p.concat(v)}, []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.sample = (size = 1)-> | |
dup = @concat() | |
[0...size].map -> | |
randomNumber = (Math.floor(Math.random() * dup.length)) | |
dup.splice(randomNumber, 1)[0] | |
.filter (item)-> item | |
console.log [1,2,3,4,5].sample() | |
console.log [1,2,3,4,5].sample(3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
# 数列の合計を返す | |
def sum | |
self.reduce(0){|memo,v| | |
memo + v.to_f | |
} | |
end | |
# 数列の平均を返す |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def one_jump str | |
str | |
.split('') | |
.map.with_index{|c, index| | |
if index % 2 === 0 | |
c | |
else | |
nil | |
end | |
}.compact.join |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let asyncFunc = () => new Promise((resolve, reject)=>{ | |
setTimeout(()=>{ | |
resolve() | |
}, 1000); | |
}); | |
let fakeFetch = async (url) =>{ | |
let result = await asyncFunc(url) | |
return `GET ${url} 200 OK` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "net/http" | |
import "encoding/json" | |
type student struct { | |
Name string | |
Mail string | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main | |
lines = STDIN.read.split(/\n/) | |
sum = {} | |
lines.each {|line| | |
name = line.match(/\((.+) \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/)[1].strip | |
sum[name] = 0 if sum[name].nil? | |
sum[name] = sum[name] + 1 | |
} | |
sum.each {|key, v| | |
puts "#{v} lines added by #{key}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name issuesかプルリクかわかりやすくする | |
// @namespace https://gist.github.com/oieioi/ | |
// @version 0.9 | |
// @description try to take over the world! | |
// @author You | |
// @match https://github.com/*/* | |
// @grant none | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
Earthquake.once do | |
module TwitterOAuth | |
class Client | |
def search_queries(q, **options) | |
q = URI.encode_www_form_component(q) | |
options = URI.encode_www_form(options) | |
get("/search/tweets.json?q=#{q}&#{options}") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Notify pull requests required your review | |
// @namespace https://gist.github.com/oieioi/ | |
// @version 0.6 | |
// @description Notify pull requests required your review | |
// @author oieioi | |
// @match https://github.com/pulls/review-requested | |
// @match https://github.com/*/*/pulls/review-requested/* | |
// @grant none | |
// ==/UserScript== |