Skip to content

Instantly share code, notes, and snippets.

View rolftimmermans's full-sized avatar

Rolf Timmermans rolftimmermans

View GitHub Profile
require "benchmark"
range = 1...1000000
n = 100
Benchmark.bmbm do |b|
b.report "r.entries.last" do
n.times do
f = range.entries.last
end
Sentence offset=0, "...ange (weather|time))":
Literal offset=0, "maybe ":
SyntaxNode offset=0, "m"
SyntaxNode offset=1, "a"
SyntaxNode offset=2, "y"
SyntaxNode offset=3, "b"
SyntaxNode offset=4, "e"
SyntaxNode offset=5, " "
Parenthesised+Parenthesised0 offset=6, "(this is|that was)":
SyntaxNode offset=6, "("
@rolftimmermans
rolftimmermans / gist:2489198
Created April 25, 2012 11:56
Demonstration of Safari font rendering issues with CSS 3D transforms
<html>
<head>
<style>
.container {
font-family: Helvetica;
font-size: 1.5em;
}
.transform {
-webkit-perspective: 150px;
@rolftimmermans
rolftimmermans / gist:3638182
Created September 5, 2012 15:15
Jbuilder benchmark
require "active_support/core_ext"
def build_json(n)
struct = Struct.new(:name, :birthyear, :bio, :url)
author = struct.new("Rolf", 1920, "Software developer", "http://example.com/")
author.instance_eval { undef each } # Jbuilder doesn't like #each on non-arrays.
now = Time.now
arr = 100.times.to_a
n.times do
json = Jbuilder.encode do |json|
@rolftimmermans
rolftimmermans / compress-folder-with-tinypng.jsx
Created June 25, 2014 14:24
Compressing all PNG images in a folder and its subfolders with TinyPNG
#target photoshop
/* Open the given file, and compress with TinyPNG. */
function compressFile(file) {
var document = open(file);
if (document.mode == DocumentMode.INDEXEDCOLOR) {
document.changeMode(ChangeMode.RGB);
}
const zmq = require("./lib")
const client = zmq.socket("dealer")
client.connect("tcp://127.0.0.1:3456")
gc()
console.log(process.memoryUsage())
for (let i = 0; i < 500; i++) {
'use strict';
const buildType = process.config.target_defaults.default_configuration;
const assert = require('assert');
const common = require('./common');
// we only check async hooks on 8.x an higher were
// they are closer to working properly
const nodeVersion = process.versions.node.split('.')[0]
let async_hooks = undefined;
function checkAsyncHooks() {