Skip to content

Instantly share code, notes, and snippets.

View zhuochun's full-sized avatar

Zhuochun zhuochun

View GitHub Profile
# this is a dirty implementation of logger that
# compiles AR queries with trace into /last_request_log.html
# the snippet is useful when optimizing performance of the endpoint
class QueryLogSubscriber < ActiveSupport::LogSubscriber
TRACE_LEVEL = :app
LINES = 5
IGNORE_CACHED_QUERIES = false
def initialize
@zhuochun
zhuochun / greeter_client.rb
Last active March 9, 2016 14:06
Ruby GRPC Memory Leak
# Sample app that connects to a Greeter service.
#
# Usage: $ path/to/greeter_client.rb
this_dir = File.expand_path(File.dirname(__FILE__))
lib_dir = File.join(this_dir, 'lib')
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
require 'grpc'
require 'helloworld_services'
#!/usr/bin/env ruby
require 'net/http'
require 'json'
begin
uri = URI('https://cdn.rawgit.com/github/gemoji/master/db/emoji.json')
resp = Net::HTTP.get_response(uri)
emoji = JSON.parse(resp.body)
num = [ARGV.first.to_i, 1].max