Skip to content

Instantly share code, notes, and snippets.

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

oieioi

🐙
🐙🐙🐙🐙🐙🐙🐙🐙🐙
View GitHub Profile
[[1,2,3],[4,5,6],[7,8,9]].reduce((p, v) => { return p.concat(v)}, [])
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)
class Array
# 数列の合計を返す
def sum
self.reduce(0){|memo,v|
memo + v.to_f
}
end
# 数列の平均を返す
def one_jump str
str
.split('')
.map.with_index{|c, index|
if index % 2 === 0
c
else
nil
end
}.compact.join
let asyncFunc = () => new Promise((resolve, reject)=>{
setTimeout(()=>{
resolve()
}, 1000);
});
let fakeFetch = async (url) =>{
let result = await asyncFunc(url)
return `GET ${url} 200 OK`
}
package main
import "net/http"
import "encoding/json"
type student struct {
Name string
Mail string
}
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}"
@oieioi
oieioi / github.user.js
Last active November 17, 2017 09:25
issuesかプルリクかわかりやすくする
// ==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==
@oieioi
oieioi / search_trace.rb
Created November 14, 2017 01:30
Earthquake plugin to search back
# 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
@oieioi
oieioi / notify-pull-requests.user.js
Last active November 29, 2017 02:37
プルリクお知らせ
// ==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==