Skip to content

Instantly share code, notes, and snippets.

View charlietanksley's full-sized avatar

Charlie Tanksley charlietanksley

View GitHub Profile
@charlietanksley
charlietanksley / example.rb
Created January 29, 2013 00:17
Ruby idioms?
def example(arg=nil)
a = [1, 2]
return a.reverse if arg
a
end
# OR
def example(arg=nil)
@charlietanksley
charlietanksley / sample_spec.rb
Created December 6, 2012 18:42
Show failures in pending blocks
RSpec.configure do |config|
config.show_failures_in_pending_blocks = true
end
describe Array do
pending 'slowest' do
expect([1, 2, 3].reverse).to eq([2])
end
it 'faster' do
@charlietanksley
charlietanksley / gist:4182544
Created December 1, 2012 14:19
Highgroove generator error
$ highgroove new does-it-work
run rails new does-it-work --skip-bundle -T -q -d postgresql from "."
run git init -q from "./does-it-work"
gsub does-it-work/Gemfile
gsub does-it-work/Gemfile
append does-it-work/Gemfile
run rvm 1.9.3-p125 do rvm --rvmrc --create 1.9.3-p125@does-it-work from "./does-it-work"
run rvm 1.9.3-p125@does-it-work do gem install bundler from "./does-it-work"
run rvm 1.9.3-p125@does-it-work do bundle install --quiet from "./does-it-work"
run rvm 1.9.3-p125@does-it-work do rails g rspec:install from "./does-it-work"
@charlietanksley
charlietanksley / gist:3789095
Created September 26, 2012 16:41
methods in blocks
class NginxLog
[snip]
def read
raw = read_source
raw.extend(Seeder::LazyEnumerable)
entries = raw.take_with_block(@count, &:interesting?)
raw.map { |entry| parse_entry(entry) }
end
@charlietanksley
charlietanksley / basic-installation
Created June 7, 2012 15:33
Problems installing MacVim with Homebrew
$ brew install macvim --override-system-vim
==> Downloading https://github.com/b4winckler/macvim/tarball/snapshot-64
Already downloaded: /Library/Caches/Homebrew/macvim-7.3-64.tgz
==> ./configure --with-features=huge --with-tlib=ncurses --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enab
==> cd src/MacVim/icons && make getenvy
==> make
Starting make in the src directory.
If there are problems, cd to the src directory and run make there
cd src && make first
mkdir objects
@charlietanksley
charlietanksley / dirname.filename.markdown
Created June 7, 2012 15:31
A test of mocking directories

Ha

See how this shows up.

@charlietanksley
charlietanksley / football.dat
Created February 28, 2012 19:54
Data Munging Kata
Source <a
href="http://sunsite.tut.fi/rec/riku/soccer_data/tab/93_94/table.eng0.01_02.html">sunsite.tut.fi/rec/riku/soccer_data/tab/93_94/table.eng0.01_02.html</a>
<pre>
Team P W L D F A Pts
1. Arsenal 38 26 9 3 79 - 36 87
2. Liverpool 38 24 8 6 67 - 30 80
3. Manchester_U 38 24 5 9 87 - 45 77
4. Newcastle 38 21 8 9 74 - 52 71
5. Leeds 38 18 12 8 53 - 37 66
@charlietanksley
charlietanksley / string_squeeze_spec.markdown
Created October 15, 2011 17:36
Rubinius, MRI 1.8, and MRI 1.9 String#squeeze and String#squeeze! specs

The behavior of String#squeeze and String#squeeze! changes from 1.8 to 1.9. You can see the difference in the two code samples below.

irb(main):009:0> `ruby -v`
=> "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.1.0]\n"
irb(main):010:0> s = '--subbookkeeper--'
=> "--subbookkeeper--"
irb(main):011:0> s.squeeze 'z-a'
=> "--subbookkeeper--"
irb(main):012:0&gt; s.squeeze! 'z-a'
@charlietanksley
charlietanksley / is_a_spec.rb
Created June 3, 2011 18:15
First pass at a RubySpec
require File.expand_path('../../../spec_helper', __FILE__)
describe "Kernel#is_a?" do
it "returns true when object really is in that class" do
obj = String.new
obj.is_a?(String).should be_true
end
it "returns true when asked about a superclass" do
obj = String.new
@charlietanksley
charlietanksley / rvm_errors
Created February 26, 2011 17:09
problems with rvm on 02/26/2011
Last login: Sat Feb 26 12:06:12 on ttys001
-bash: /Users/charlietanksley/.rvm/scripts/utility: line 457: syntax error near unexpected token `('
-bash: /Users/charlietanksley/.rvm/scripts/utility: line 457: ` \rm -rf "${rvm_tmp_path}/$1"*(N) >/dev/null 2>&1'
-bash: __rvm_conditionally_add_bin_path: command not found
~
$ rvm list
-bash: __rvm_load_rvmrc: command not found
-bash: __rvm_initialize: command not found