Skip to content

Instantly share code, notes, and snippets.

Adam Roben aroben

Block or report user

Report or block aroben

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aroben
aroben / stackprof-to-flamegraph
Created Mar 6, 2017
Script to generate flamegraphs from Ruby stackprof profiles
View stackprof-to-flamegraph
#!/bin/sh
# First generate a profile using https://github.com/tmm1/stackprof
# StackProf.run(raw: true, out: "tmp/stackprof.dump) { something_expensive }
# Then run this script
# $ stackprof-to-flamegraph tmp/stackprof.dump
set -e
if [ "$STACKCOLLAPSE" = "1" ]; then
template="/tmp/stackprof-$$"
@aroben
aroben / git-commit-editor.vim
Last active Jan 11, 2019
Vim script to show git commit diff in vertical split while writing commit messages
View git-commit-editor.vim
" Put this in your .vimrc and whenever you `git commit` you'll see the diff of your commit next to your commit message.
" For the most accurate diffs, use `git config --global commit.verbose true`
" BufRead seems more appropriate here but for some reason the final `wincmd p` doesn't work if we do that.
autocmd VimEnter COMMIT_EDITMSG call OpenCommitMessageDiff()
function OpenCommitMessageDiff()
" Save the contents of the z register
let old_z = getreg("z")
let old_z_type = getregtype("z")
@aroben
aroben / 01_process_stats.rb
Last active Nov 7, 2016
sketch of a ProcessUtilization rework
View 01_process_stats.rb
class ProcessStats
include Singleton
def add_source(source)
@sources << source
end
def snapshot
Snapshot.new(@sources)
end
@aroben
aroben / arraycap.md
Last active Sep 23, 2016
ruby array length vs. capacity
View arraycap.md
@aroben
aroben / license.diff
Last active Aug 29, 2015
Patch to add a license to Genshi.tmbundle
View license.diff
Index: textmate/Genshi.tmbundle/COPYING
===================================================================
--- textmate/Genshi.tmbundle/COPYING (revision 0)
+++ textmate/Genshi.tmbundle/COPYING (working copy)
@@ -0,0 +1,28 @@
+Copyright (C) 2014 Edgewall Software
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
@aroben
aroben / hubot-commands.sh
Created Nov 12, 2014
Find most common Hubot commands from Campfire
View hubot-commands.sh
#!/bin/sh
set -e
curl -s -u $CAMPFIRE_TOKEN:X https://$CAMPFIRE_ACCOUNT.campfirenow.com/room/$CAMPFIRE_ROOM/transcript.json | jq -r '.messages | .[] | select(.body != null) | .body | select(startswith("/"))' | cut -d' ' -f1 | sort | uniq -c | sort -rn
@aroben
aroben / hissuegram.rb
Last active Aug 29, 2015
Script to generate a histogram of GitHub issue age
View hissuegram.rb
#!/usr/bin/env ruby
# Usage: GITHUB_TOKEN=yourtoken hissuegram.rb owner/repo
require "octokit"
client = Octokit::Client.new(:access_token => ENV["GITHUB_TOKEN"], :auto_paginate => true)
issues = client.issues ARGV[0], :state => :open
dates = issues.map { |i| i["created_at"] }
@aroben
aroben / index.html
Last active Aug 29, 2015
Test which Unicode code points are rendered as emoji on your system
View index.html
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: monospace, "Segoe UI Emoji";
}
</style>
</head>
<body>
@aroben
aroben / deleters.js
Last active Aug 29, 2015
Find who has deleted more code than they've added; run on https://github.com/rails/rails/graphs/contributors or similar
View deleters.js
$.makeArray($('.capped-card')).map(function(e) {
return [$(e).find('.aname').text(), parseInt($(e).find('.a').text().replace(/,/g, ''), 10), parseInt($(e).find('.d').text().replace(/,/g, ''), 10)];
}).filter(function(a) {
return a[2] > a[1];
}).map(function(a) {
return [a[0], a[2] - a[1], a[2] / a[1]];
}).sort(function(a, b) {
return b[1] - a[1];
}).map(function(a) {
return a[0] + " removed " + a[1] + " lines (" + a[2].toFixed(2) + "x as many lines as they added)";
@aroben
aroben / README.md
Last active Aug 29, 2015
Chromium Infinite Scrolling Demo
View README.md

This demo comes from Chromium's source repository. See the original here.

The scrollable area represents 500 "virtual" items (kNumberOfItems) using 30 "physical" DOM elements (kPhysicalCount). As elements get scrolled out of view to the top, they get moved down to the bottom via -webkit-transform: translate3d(0, NNNpx, 0) and their contents get replaced with the appropriate "virtual" item. requestAnimationFrame() is used to ensure that updates only happen once per repaint of the window.

You can’t perform that action at this time.