Skip to content

Instantly share code, notes, and snippets.

Building Pingboard. Accepting JavaScript. Still loving Rails. Telling jokes.

Adam Keys therealadam

Building Pingboard. Accepting JavaScript. Still loving Rails. Telling jokes.
View GitHub Profile
therealadam / ideavimrc
Created Sep 7, 2021
vimrc for use with JetBrains IDEs
View ideavimrc
set surround
set commentary
set easymotion
set ideajoin
set NERDTree
set relativenumber
set number
map \r :action RunAnything<CR>
therealadam / SketchSystems.spec
Last active Sep 2, 2018
A Markdown and Unfurling Saavy Text Cell
View SketchSystems.spec
A Markdown and Unfurling Saavy Text Cell
Empty Cell*
click inside -> Edit Cell
Edit Cell
type markdown -> Edit Cell
type URL -> Edit Cell with unfurl
Edit Cell with unfurl
click save -> Populated Cell
click outside -> Populated Cell
Populated Cell
therealadam / maps.rb
Created Mar 25, 2016
Can you chain maps and eat cake too?
View maps.rb
Allocations -------------------------------------
null 0/0 alloc/ret 0/0 strings/ret
mega no work 1/0 alloc/ret 0/0 strings/ret
mega w/ locals 1446/114 alloc/ret 50/50 strings/ret
chained 1334/0 alloc/ret 50/0 strings/ret
lazy chained 2102/0 alloc/ret 50/0 strings/ret
Warming up --------------------------------------
null 151.895k i/100ms
mega no work 6.384k i/100ms
mega w/ locals 135.000 i/100ms
therealadam / lol.rb
Last active Dec 12, 2015
I took producer.rb, added threads and made it two orders of magnitude slower. Thus was born, lol.rb. (NOW LOLFAST)
View lol.rb
require 'thread'
require 'ffaker'
require 'json'
def new_message
text = Faker::HipsterIpsum.sentences(3)
metrics = {
temp: rand(110), # degrees F
mass: rand(100), # kilograms
speed: rand(70) # miles per hour
View simplequeue.rb
# Simple Queue
# ------------
# A riff on bitly's HTTP-based simple queue[1]
# [1]
# Is it any good?
# ===============
therealadam / gist:2953970
Created Jun 19, 2012
Baby's first concurrent program
View gist:2953970
require 'thread'
require 'timeout'
module Work
@queue =
@n_threads = 2
@workers = []
@running = true
View postbin.rb
# Postbin
# -------
# A postbin for your localhost.
# Usage
# =====
# It's a Unix program. You run it from a shell.
# $ ./postbin [-p PORT]
therealadam /
Created Feb 22, 2012
Run focused unit tests in Vim, with a little help from Ruby.
  • Move focus to somewhere on your PATH
  • Drop focus.vim in ~/.vim/plugins
  • Put focus on a key. I went with nnoremap <leader>tf :call Focus().
  • Open a test/unit file, put your cursor inside a test method and run focus.
  • Profit
therealadam / gist:1862005
Created Feb 19, 2012
A lenient cane script for a Rails project
View gist:1862005
max_violations=0 # We run a tight ship...
complexity_max=60 # ...but we've got stuff to clean up
cane \
--max-violations $max_violations \
--abc-glob '{app,lib}/**/*.rb' \
--abc-max=$complexity_max \
--no-style \
therealadam / gist:1627058
Created Jan 17, 2012
Sugar for swallowing exceptions
View gist:1627058
# Suppose we're going to have a bunch of code like the following
# boilerplate (ignore the unfortunate nil propagation)
@city = begin
rescue GizmoStore::NotFound
# I can't decide if this is useful boilerplate elimination or
# saccharine ivory tower abstraction.