Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am nate on github.
  • I am natesutton (https://keybase.io/natesutton) on keybase.
  • I have a public key ASA_ddu-DEDagScIhggwQs12FUQ2F-8wKK_MUsW_ATBpbwo

To claim this, I am signing this object:

@nate
nate / orgmode.gcemode
Created Oct 8, 2017 — forked from mpeuster/orgmode.gcemode
Highlights headings, TODOs, checkboxes, and links in Emacs Orgmode files
View orgmode.gcemode
{
// GoCoEdit demo mode - visit http://gocoedit.com/docs/custommodes for more information
"name": "orgfile", // The name of the Mode
"ext":[
// An Array of file extensions to associate with your mode
"org", "ORG", "Org",
],
"dash_docsets": "", // Docsets to search if you are using the dash app
"tokenizer":[
View intro.scss
// Cascading and Mutability cause pain
// and all sorts of trouble for your brain
// so quit being pedantic
// those styles are gigantic
// and Functional CSS is quite sane
// http://mrmrs.io/writing/2016/03/24/scalable-css/
// https://marcelosomers.com/writing/rationalizing-functional-css/
// https://blog.colepeters.com/building-and-shipping-functional-css/
@nate
nate / assert_queries.rb
Created Sep 19, 2016 — forked from pch/assert_queries.rb
assert_queries - rails 4
View assert_queries.rb
# Assertion for checking the number of queries executed within the &block
def assert_queries(num = 1, &block)
queries = []
callback = lambda { |name, start, finish, id, payload|
queries << payload[:sql] if payload[:sql] =~ /^SELECT|UPDATE|INSERT/
}
ActiveSupport::Notifications.subscribed(callback, "sql.active_record", &block)
ensure
assert_equal num, queries.size, "#{queries.size} instead of #{num} queries were executed.#{queries.size == 0 ? '' : "\nQueries:\n#{queries.join("\n")}"}"
@nate
nate / Generate tmux 2.1 packages on ubuntu 12.04
Last active Apr 9, 2016 — forked from saiqulhaq/latest-tmux-1.7 on ubuntu12.04
Generate tmux 2.1 packages on ubuntu 12.04
View Generate tmux 2.1 packages on ubuntu 12.04
sudo apt-get install git checkinstall automake libtool pkg-config alien
sudo apt-get build-dep tmux
git clone git@github.com:tmux/tmux.git
cd tmux
git checkout 2.1
./autogen.sh
./configure --prefix=/usr/local
make
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@nate
nate / sortable_bools.rb
Created Feb 11, 2014
Make TrueClass and FalseClass sortable in ruby. Don't ever use this.
View sortable_bools.rb
class TrueClass
include Comparable
def <=>(other)
case other
when FalseClass
1
when TrueClass
0
else
View cond_variable_wtf.rb
require 'thread'
def signal_benchmark(klass, iterations)
mutex = Mutex.new
cond = klass.new
mutex.synchronize do
Thread.new do
iterations.times { |n| mutex.synchronize { print "cond.signal\n"; cond.signal } }
end
@nate
nate / offline_view_rendering.rb
Created Jun 20, 2013
We use this for indexing our documentation offline. This is known to work with Rails 3.2.13. A rake task renders all the views, strips all tags, mass deletes the docs from the index, and then batch inserts the new ones in the index. We need to render the views since helpers often generate text. The bonus of doing it this way is that the people m…
View offline_view_rendering.rb
#
# Examples:
#
# OfflineController.new.render_inline(%{<%= foos_path %>})
# # => "/foos"
#
# OfflineController.new.render_template_inline("/path/to/template.html.erb")
# # => "..."
#
View README.md

RSpec Around All

Provides around(:all) hooks for RSpec.

Usage

In your Gemfile:

gem 'rspec_around_all', git: 'git://gist.github.com/2005175.git'