Skip to content

Instantly share code, notes, and snippets.

View jtmkrueger's full-sized avatar
🎉
Working from home

John Krueger jtmkrueger

🎉
Working from home
View GitHub Profile
--type-add=js=.ejs
--type-add=ruby=.erb
--type-add=css=.sass
--type-add=ruby=.feature
@sstephenson
sstephenson / gist:1120938
Created August 2, 2011 19:08
Quick guide to installing rbenv
# Clone rbenv into ~/.rbenv
git clone git@github.com:sstephenson/rbenv.git ~/.rbenv
# Add rbenv to your PATH
# NOTE: rbenv is *NOT* compatible with rvm, so you'll need to
# remove rvm from your profile if it's present. (This is because
# rvm overrides the `gem` command.)
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
exec $SHELL

Fibur

Fibur is a library that allows concurrency during Ruby I/O operations without needing to make use of callback systems. Traditionally in Ruby, to achieve concurrency during blocking I/O operations, programmers would make use of Fibers and callbacks. Fibur eliminates the need for wrapping your I/O calls with Fibers and a callback. It allows you to write your blocking I/O calls the way you normally would, and still have concurrent execution during those I/O calls.

Example

Say you have a method that fetches data from a network resource:

@panicsteve
panicsteve / gist:1641705
Created January 19, 2012 18:26
Form letter template for acquired startups
Dear soon-to-be-former user,
We've got some fantastic news! Well, it's great news for us anyway. You, on
the other hand, are fucked.
We've just been acquired by:
[ ] Facebook
[ ] Google
[ ] Twitter
@elskwid
elskwid / verify_fingerprint.rb
Created March 7, 2012 18:42
Display the fingerprints for all your public keys
#! /usr/bin/ruby
home_dir = ENV["HOME"]
ssh_dir = "#{home_dir.strip}/.ssh/*.pub"
puts "Checking #{ssh_dir} ..."
puts
Dir["#{home_dir.strip}/.ssh/*.pub"].each do |pk|
puts "Fingerprint for #{pk}"
fingerprint = `ssh-keygen -lf #{pk}`
@ordinaryzelig
ordinaryzelig / minitest_spec_expectations.md
Last active December 10, 2022 13:34
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@olistik
olistik / gist:2627011
Last active August 12, 2021 06:39
Ubuntu 12.10 setup (rbenv/RVM, Janus, PostgreSQL)

Ubuntu 12.10 setup (rbenv/RVM, Janus, PostgreSQL)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git curl
  • Copy/paste from the command line:
@zenkay
zenkay / gist:3237860
Created August 2, 2012 15:19
Installation tips for RVM/Ruby on OSX 10.8 Mountain Lion

Ruby, RVM and Mountain Lion

Key problems

Mountain Lion (10.8) has three main difference compared to Lion (10.7):

  • XCode 4.4 does not install Command Line Tools by default
  • X11 isn't available anymore
  • The installed version of OpenSSL has some bugs

How to work around

@leh
leh / restart_tmux
Created October 18, 2012 15:58
start or restore a tmux session named after your current working directory
# Switching projects like mad?
# t: start or restore a tmux session named after your current working directory
#
# e.g. calling t in /home/project/awesome_project will reattach the tmux session named
# awesome_project or create a new one
t() { tmux attach-session -t $(pwd | awk -F/ '{print $NF}') || tmux new-session -s $(pwd | awk -F/ '{print $NF}') ; }