Skip to content

Instantly share code, notes, and snippets.

View yuroyoro's full-sized avatar
🍣
🍣

しいたけ yuroyoro

🍣
🍣
View GitHub Profile
object GeoHash{
val base32 = "0123456789bcdefghjkmnpqrstuvwxyz"
def encode( longtitude:Double, latitude:Double, range:Double) = {
def asBit( d:Double,max:Double,min:Double ) : List[Boolean] = {
val mid = ( max + min ) / 2
var res = ( d >= mid )
val (m,n) = if( res ) (max,mid) else (mid,min)
if( Math.abs( m - n ) <= range )
res :: Nil
2 :水先案名無い人:2011/12/03(土) 11:12:19.45 ID:bTIMyqpW0
         ,;' '" '' ゛''" ゛' ';;,,
      (rヽ,;''"""''゛゛゛'';, ノr)
      ,;'゛ i _  、_ iヽ゛';,    お前それ関数型言語でも同じ事言えんの?
      ,;'" ''| ヽ・〉 〈・ノ |゙゛ `';,
      ,;'' "|   ▼   |゙゛ `';,
      ,;''  ヽ_人_ /  ,;'_
     /シ、  ヽ⌒⌒ /   リ \
    |   "r,, `"'''゙´  ,,ミ゛   |
@yuroyoro
yuroyoro / README.md
Last active November 30, 2017 08:21
Sentryをdocker-composeで。
  1. docker run --rm sentry config generate-secret-key でSECRET_KEYを生成する
  2. SECRET_KEYを環境変数にいれる export SENTRY_SECRET_KEY="your generated secret key"
  3. docker-compose up -d でサービスあげる。
  4. docker-compose run -rm sentry sentry upgrade で初期設定する
  5. docker-compmse restart で再起動
  6. Go http://localhost:9000 and get sentry!
Received: by 10.170.200.130 with SMTP id r124csp566647yke;
Mon, 26 Jan 2015 17:40:13 -0800 (PST)
X-Received: by 10.236.7.39 with SMTP id 27mr10135662yho.16.1422322813088;
Mon, 26 Jan 2015 17:40:13 -0800 (PST)
Authentication-Results: mx.google.com;
spf=none (google.com: yasuhiro@wahlandcase.com does not designate permitted sender hosts) smtp.mail=yasuhiro@wahlandcase.com;
dkim=pass header.i=@wahlandcase.com
Received-SPF: none (google.com: yasuhiro@wahlandcase.com does not designate permitted sender hosts) client-ip=210.224.168.166;
Received: by 10.170.124.9 with POP3 id q9mf1527070ykb.31;
Mon, 26 Jan 2015 17:40:12 -0800 (PST)
Delivered-To: helmettomo@gmail.com
Received: by 10.129.121.20 with SMTP id u20csp861396ywc;
Mon, 19 Sep 2016 01:14:24 -0700 (PDT)
X-Received: by 10.13.204.87 with SMTP id o84mr24656150ywd.299.1474272863926;
Mon, 19 Sep 2016 01:14:23 -0700 (PDT)
Authentication-Results: mx.google.com;
spf=neutral (google.com: 133.242.250.102 is neither permitted nor denied by best guess record for domain of khorie@wanderlust.co.jp) smtp.mailfrom=khorie@wanderlust.co.jp;
dkim=pass header.i=@wanderlust-co-jp.20150623.gappssmtp.com
Received-SPF: neutral (google.com: 133.242.250.102 is neither permitted nor denied by best guess record for domain of khorie@wanderlust.co.jp) client-ip=133.242.250.102;
Received: by 10.129.42.135 with POP3 id q129mf23827744ywq.2;
Received: by 10.202.106.74 with SMTP id f71csp251115oic;
Tue, 4 Jul 2017 19:42:52 -0700 (PDT)
X-Received: by 10.202.85.212 with SMTP id j203mr27110703oib.174.1499222571214;
Tue, 04 Jul 2017 19:42:51 -0700 (PDT)
Authentication-Results: mx.google.com;
spf=neutral (google.com: 133.242.250.104 is neither permitted nor denied by best guess record for domain of a-takeda@shashoku-collection.jp) smtp.mailfrom=a-takeda@shashoku-collection.jp;
dkim=neutral (body hash did not verify) header.i=@shashoku-collection-jp.20150623.gappssmtp.com header.b=MZougrB6
Received-SPF: neutral (google.com: 133.242.250.104 is neither permitted nor denied by best guess record for domain of a-takeda@shashoku-collection.jp) client-ip=133.242.250.104;
Received: by 10.202.86.195 with POP3 id k186mf60078182oib.1;
Tue, 04 Jul 2017 19:42:51 -0700 (PDT)
@yuroyoro
yuroyoro / Uber-migrated-pg-to-mysql.md
Created July 27, 2016 06:28
UberのPostgresqlからNoSQL on MySQLへの移行を読んでざっくりまとめた

Why Uber Engineering Switched from Postgres to MySQL - Uber Engineering Blog のまとめ

Posgresqlだと

  • pgは追記型なので少しの更新でも多くのdiskへのwriteがおきる
  • カラムを一つ更新しただけで多くのindexの書き換えが起こる
  • よって、replicationはWALを送るので更新が多いとWALが大量に送られる
  • repcliationでは物理的なdiskの変更を送る
  • DC間でレプリするときつい
  • bugがあってreplica間でMVCCの不整合が起きる
@yuroyoro
yuroyoro / attr_inquireable.rb
Last active May 10, 2017 20:35
AttrInquirable wraps value of attribute in ActiveSupport::StringInquirer.
# AttrInquirable
# wraps value of attribute in ActiveSupport::StringInquirer.
#
# Usage:
#
# class Person < ActiveRecord::Base
# attr_inquireable :status
# end
#
# person = Person.new(:status => :pending)
import java.util.*;
import java.util.function.*;
public class Fold {
// 自作fold関数
// 引数に List<T> と、2引数の演算を行うBiFunction<T, T, T>をとって、
// listを順番にfで畳み込む
public static <T> T fold(List<T> list, BiFunction<T, T, T> f) {
T res = list.get(0);
@yuroyoro
yuroyoro / shared.js
Created February 6, 2017 06:46
webpacker.gemでapp/javascript/packs 以下にディレクトリを掘った場合に対応したconfig/webpack/shared.js
var path = require('path')
var glob = require('glob')
var extname = require('path-complete-extname')
module.exports = {
entry: glob.sync(path.join('..', 'app', 'javascript', 'packs', '**', '*.js*')).reduce(
function(map, entry) {
var relpath = path.relative(path.join('..', 'app', 'javascript', 'packs'), entry);
var basename = path.basename(relpath, extname(relpath));