Skip to content

Instantly share code, notes, and snippets.

If you add the following CSS rule:

details > details {
  padding-left: 20px;
}

The following markup becomes a nested outline view:

@aroben
aroben / stackprof-to-flamegraph
Created March 6, 2017 21:20
Script to generate flamegraphs from Ruby stackprof profiles
#!/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 March 30, 2023 07:57
Vim script to show git commit diff in vertical split while writing commit messages
" 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 November 7, 2016 16:26
sketch of a ProcessUtilization rework
class ProcessStats
include Singleton
def add_source(source)
@sources << source
end
def snapshot
Snapshot.new(@sources)
end
@aroben
aroben / arraycap.md
Last active September 23, 2016 16:24
ruby array length vs. capacity
@aroben
aroben / license.diff
Last active August 29, 2015 14:09
Patch to add a license to Genshi.tmbundle
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 November 12, 2014 19:34
Find most common Hubot commands from Campfire
#!/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 August 29, 2015 14:06
Script to generate a histogram of GitHub issue age
#!/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 August 29, 2015 14:04
Test which Unicode code points are rendered as emoji on your system
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: monospace, "Segoe UI Emoji";
}
</style>
</head>
<body>
@aroben
aroben / deleters.js
Last active August 29, 2015 14:04
Find who has deleted more code than they've added; run on https://github.com/rails/rails/graphs/contributors or similar
$.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)";