Skip to content

Instantly share code, notes, and snippets.

View therealadam's full-sized avatar
🍔
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
therealadam / ideavimrc
Created September 7, 2021 14:52
vimrc for use with JetBrains IDEs
set surround
set commentary
set easymotion
set ideajoin
set NERDTree
set relativenumber
set number
map \r :action RunAnything<CR>
@therealadam
therealadam / SketchSystems.spec
Last active September 2, 2018 18:37
A Markdown and Unfurling Saavy Text Cell
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
#!/usr/bin/env ruby
#
# Seeking to answer man's eternal question "I wonder how many little Git
# repositories I have just floating around in my home directory. Further, I
# wonder how many actually have a remote somewhere."
#
# Usage:
#
# Search for Git repositories in the specified directory
# > ruby git_finder.rb some_dir another_dir ...
@therealadam
therealadam / maps.rb
Created March 25, 2016 19:34
Can you chain maps and eat cake too?
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
therealadam / lol.rb
Last active December 12, 2015 02:28
I took producer.rb, added threads and made it two orders of magnitude slower. Thus was born, lol.rb. (NOW LOLFAST)
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
# Simple Queue
# ------------
#
# A riff on bitly's HTTP-based simple queue[1]
#
# [1] https://github.com/bitly/simplehttp/blob/master/simplequeue/simplequeue.c
#
# Is it any good?
# ===============
#
@therealadam
therealadam / gist:2953970
Created June 19, 2012 12:48
Baby's first concurrent program
# http://weblog.therealadam.com/2012/06/19/getting-started-with-ruby-concurrency-using-two-simple-classes/
require 'thread'
require 'timeout'
module Work
@queue = Queue.new
@n_threads = 2
@workers = []
@running = true
# Postbin
# -------
# A postbin for your localhost.
#
# Usage
# =====
#
# It's a Unix program. You run it from a shell.
#
# $ ./postbin [-p PORT]
@therealadam
therealadam / README.md
Created February 22, 2012 15:40
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
therealadam / gist:1862005
Created February 19, 2012 04:36
A lenient cane script for a Rails project
#!/bin/sh
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 \