Skip to content

Instantly share code, notes, and snippets.

@yoppi
yoppi / unicorn_vs_puma.md
Last active February 12, 2017 08:36
Unicorn vs Puma

Unicorn

 < ab -n 10000 -c 100 'http://127.0.0.1:8080/loadtest'
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
@yoppi
yoppi / each_vs_compact_map_uniq_bench.rb
Created February 7, 2017 02:08
each君 vs enumerable君
require 'benchmark'
N = 5
TRY = 1_000_000
campaign = Struct.new("Campagin", :id)
campaings = []
N.times { |i| campaings << campaign.new(i+1) }
def each(ary)
@yoppi
yoppi / sleep.js
Last active December 9, 2016 09:46
jsでのsleep関数
//
// sleep関数 pure js版
//
function sleep(x) {
return function(func) {
setTimeout(function() {
console.log(x);
func();
}, 1000);
@yoppi
yoppi / xhrImageLoad.js
Created September 5, 2016 09:33
同じsrcなんだけど実は裏で画像が更新されていて変化したタイミングで取ってきたいという贅沢な悩みを解決するやつ
'use strict';
// LastModifiedの変化を検知してimgをロードする
let $ = require('jquery');
module.exports = (imgSrc, callback) => {
let beforeLastModified;
let downloadImg = () => {
$.get(imgSrc, (data, status, xhr) => {
@yoppi
yoppi / ab-iris.txt
Last active July 9, 2016 10:08
benchmark net/http vs iris
< ab -n 1000 -c 10 'http://127.0.0.1:8080/' [~/local/go/1.7-rc1]
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c
index ea29f2e..ff971f3 100644
--- a/bin/varnishtest/vtc_http2.c
+++ b/bin/varnishtest/vtc_http2.c
@@ -1070,10 +1070,10 @@ cmd_var_resolve(struct stream *s, char *spec, char *buf)
*/
else if (!strcmp(spec, "stream.window")) {
if (s->id) {
- snprintf(buf, 20, "%ld", s->ws);
+ snprintf(buf, 20, "%lld", s->ws);
@yoppi
yoppi / a.js
Created March 11, 2016 03:10
custom mangle props
// ObjectKeyVal
// Dot
// Sub
var obj = {
'hoge': 'val'
};
var obj2 = {
foo: 'val'
@yoppi
yoppi / calc.go
Last active December 30, 2015 16:09
Ottoを使った計算機
package main
import (
"bufio"
"fmt"
"github.com/robertkrimen/otto"
"io/ioutil"
"os"
"regexp"
"strconv"
@yoppi
yoppi / aggregate_sinatra_action_log.rb
Last active December 27, 2015 07:19
Aggregate sinatra log
#!/usr/bin/env ruby
#
# Aggregate access times, rtt group by action
#
# Usage:
# [premise]
# * Enable access log on sinatra
# * Access log format is:
#
# 18:48:27 web.1 | 127.0.0.1 - - [27/Oct/2013 18:48:27] "GET / HTTP/1.1" 200 14700 0.4229
@yoppi
yoppi / clickCookie.js
Created September 16, 2013 16:33
クッキークリックするやつ
function sleep(msec) {
return function(func) {
setTimeout(function() {
func();
}, msec);
}
}
function loop(func, msec) {
sleep(msec)(function(){