Skip to content

Instantly share code, notes, and snippets.

Back traces
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+
| Name | Time (ms) |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+
| +---org.jruby.util.ByteList.lookup(String) | 60 100 % |
| |
require "dalli"
module ActiveSupport::Cache
# unlike the "official" dalli store this subclasses the abstract Store class which handles nil values properly
# also implement the local cache strategy to avoid network hits
class SimpleDalliStore < Store
def initialize(*addresses)
opts = addresses.extract_options!
gem 'rails', "~> 3.2"
gem 'squeel', "~> 1.1"
gem 'sqlite3'
require "active_record"
require "squeel"
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
class A < ActiveRecord::Base
@the8472
the8472 / testcase.rb
Created October 25, 2013 13:48
squeel + globalize breakage
#!/usr/bin/env ruby
gem 'activerecord', "~> 3.2.0"
gem "squeel"
gem "globalize", "~> 3.0.0"
gem 'sqlite3'
require "active_record"
require "squeel"
#require "globalize"
@the8472
the8472 / ci.rb
Created August 28, 2014 17:48
Continuous building for firefox addons
#!/usr/bin/ruby
require "rubygems"
gem "rb-inotify"
require "rb-inotify"
notifier = INotify::Notifier.new
event_handler = proc do
puts "change detected, running CI"
buildView: function() {
let window = windowUtils.getMostRecentBrowserWindow();
let doc = window.document;
let content = doc.getElementById("appcontent");
let splitter = doc.createElementNS(XUL_NS, 'splitter');
splitter.setAttribute("resizeafter","closest")
splitter.setAttribute("resizebefore","closest")
@the8472
the8472 / gist:ae462c8f8d598a7be671
Created April 22, 2015 00:51
JMH bench for custom executor
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Measurement;
// ==UserScript==
// @name test
// @namespace https://github.com/the8472
// @include *
// @version 1
// @grant GM_setValue
// @grant GM_getValue
// @run-at document-end
// ==/UserScript==
@the8472
the8472 / replace-channel.js
Created December 17, 2015 08:41
replacing a channel instead of calling `redirect()`
"use strict";
const { Cc, Ci, Cr } = require('chrome');
const ioservice = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
const events = require("sdk/system/events");
const listener = function(event) {
let {subject, type, data} = event;
### remote RPCs
Method REQ | RSP Errors
PING 3832900629 | 3832944684 0
FIND_NODE 15033719926 | 15028735737 0
GET_PEERS 30474134400 | 30482866044 0
ANNOUNCE_PEER 3739103559 | 3541140713 198040816
GET 661604 | 661600 0
PUT 76383 | 61719 14664
UNKNOWN 120320970 | 120321404 62307537