Skip to content

Instantly share code, notes, and snippets.

/* nghttp2_on_frame_recv_callback: Called when nghttp2 library
received a complete frame from the remote peer. */
static int on_frame_recv_callback(nghttp2_session *session,
const nghttp2_frame *frame, void *user_data) {
std::cout << "RECV:: ";
switch (frame->hd.type) {
case NGHTTP2_DATA:
std::cout << "NGHTTP2_DATA" << std::endl;
break;
#!/usr/bin/env ruby
# TODO (temporary here, we'll move this into the Github issues once
# redis-trib initial implementation is completed).
#
# - Make sure that if the rehashing fails in the middle redis-trib will try
# to recover.
# - When redis-trib performs a cluster check, if it detects a slot move in
# progress it should prompt the user to continue the move from where it
# stopped.
@tomykaira
tomykaira / dpz.js
Last active November 15, 2015 12:56
PDF-ize DPZ articles with Phantomjs
var execFile = require("child_process").execFile,
page = require('webpage').create(),
system = require('system'),
workdir = null,
knownUrls = [],
files = []
;
function safeExit(exitCode) {
if (workdir)
@tomykaira
tomykaira / nginx.conf
Created November 6, 2015 08:40
log ssl_client_verify to stdout
+ log_format combined2 '$remote_addr - $remote_user [$time_local] '
+ '"$request" $status $body_bytes_sent '
+ '"$http_referer" "$http_user_agent" $ssl_client_verify';
+ access_log /dev/stdout combined2;
@tomykaira
tomykaira / gist:82ec6843bf768a16bc82
Created September 25, 2015 14:24
windows 10 キー書き換え
kbd106.dll を用意する。
Win8 だとビルドできたが 10 ではできなかったので
http://www.codeproject.com/Articles/439275/Loading-keyboard-layout-KbdLayerDescriptor-in
で C:\Windows\system32\kbd106.dll をロードし、好みの状態になるようにバイナリエディタで書き換える --
syswow にもあるが、OS は system32 のほうを使っている、ビット長が違うこともあり、中身は異なるので注意。
win 10 だと 0xD70 あたりからが数字キー
変換、無変換はキーがテーブルになかったため、 scancode -> VK 変換のテーブル (0xA80-0xC20) をいじって 変換
(0x79): 0x041C -> OEM8(0xDF), 無変換(0x7b):0x041D -> 7(0x0037)
に読み替え、未使用だった OEM8 をすべて _ にしている
@tomykaira
tomykaira / select-all.js
Created September 21, 2015 15:27
Select all results from chrome://history. be sure that history iframe is selected.
var arrayMethods = Object.getOwnPropertyNames( Array.prototype );
arrayMethods.forEach( attachArrayMethodsToNodeList );
function attachArrayMethodsToNodeList(methodName)
{
if(methodName !== "length") {
NodeList.prototype[methodName] = Array.prototype[methodName];
}
};
@tomykaira
tomykaira / deploy.rb
Created September 19, 2015 17:23
Capistrano config helper to retrieve automatically retrieve running instances to deploy
# deploy.rb
def retrieve_instances(name_prefix)
require 'aws-sdk'
next_token = nil
dns_list = []
begin
resp = Aws::EC2::Client.new.describe_instances(
filters: [{name: "tag:private:service", values: ['my-service']}],
next_token: next_token)
resp.reservations.each do |r|
@tomykaira
tomykaira / private.rb
Last active September 21, 2015 09:00
if Rails.env.development?
class DisableAssetsLogger
def initialize(app)
@app = app
Rails.application.assets.logger = Logger.new('/dev/null')
end
def call(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
git bisect start -- first_bad success success ...
git bisect run test command
class ClockRadio
on = self.instance_method(:on!)
define_method(:on!) do
on.bind(self).call
@display_time = true
end
def display_time?
@display_time