Skip to content

Instantly share code, notes, and snippets.

@amarshall
amarshall / performance-growth.rb
Created February 5, 2015 15:38
CanCanCan performance scripts
require 'bundler'
require 'csv'
Bundler.setup
require 'cancan'
NUM_SUBJECTS = 1..100
# returns µs
def time &block
before = Time.now.to_r
# Benchmarking for http://stackoverflow.com/questions/9538090
require 'benchmark'
require 'active_support/core_ext'
events = [{id:2, start:"3:30",break:30,num_attendees:14},{id:3, start:"3:40",break: 40,num_attendees:4},{id:4, start:"4:40",break:10,num_attendees:40}]
time = Benchmark.bm(10) do |bm|
bm.report("amarshall 1") do
10000.times do
require 'guard/guard'
module ::Guard
class Ant < ::Guard::Guard
def start
run_on_change nil
end
def run_on_change(paths)
system %q{bash -ic "ant compile"}
% make part1_test
g++ -Wall -Wextra -Werror -Wformat=2 -Wfloat-equal -Wshadow -Wwrite-strings -Winit-self -pedantic-errors -Wno-long-long -g -O0 -c Part1/test.cpp -o Part1/test.o
In file included from Part1/test.cpp:1:
Part1/List.hpp: In member function ‘bool cs540::List<T>::operator==(const cs540::List<T>&)’:
Part1/List.hpp:138: error: a function-definition is not allowed here before ‘{’ token
Part1/List.hpp:139: error: ‘bool cs540::operator<(const cs540::List<T>&)’ must take exactly two arguments
In file included from /usr/include/unistd.h:72,
from /usr/include/c++/4.2.1/bits/os_defines.h:61,
from /usr/include/c++/4.2.1/bits/c++config.h:41,
from /usr/include/c++/4.2.1/iostream:44,
@amarshall
amarshall / gist:1186761
Created September 1, 2011 17:48
Homebrew: clisp fails to install
% brew update && brew missing && brew doctor
Already up-to-date.
Your system is raring to brew.
% brew install -v --use-gcc clisp
==> Downloading http://ftp.gnu.org/pub/gnu/clisp/release/2.49/clisp-2.49.tar.bz2
File already downloaded in /Users/amarshall/Library/Caches/Homebrew
/usr/bin/tar xf /Users/amarshall/Library/Caches/Homebrew/clisp-2.49.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/clisp/2.49 --with-readline=yes
./configure --prefix=/usr/local/Cellar/clisp/2.49 --with-readline=yes
# Loads the specified gem from RVM's current @global gemset if using
# Bundler and not included in the current Gemfile. Falls back
# accordingly if not using Bundler or RVM.
#
# @note Doesn't load gems not loaded by Bundler if using Bundler and
# not using RVM, or if gem is located somewhere other than the
# @global gemset.
# @param [String] The gem to require
# @raise [LoadError] If the gem couldn't be loaded
# Adapted from <https://gist.github.com/794915>