Skip to content

Instantly share code, notes, and snippets.

View bratta's full-sized avatar
:shipit:
Busy Earning

Tim Gourley bratta

:shipit:
Busy Earning
View GitHub Profile
@bratta
bratta / test_spec.rb
Last active August 29, 2015 14:15
It's easy to accidentally a capital letter and segfault ruby
# Causes ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
# to segfault with rspec 2.14.1
# This class could be anything
class Foo; @bar = nil; class << self; attr_accessor :bar; end; end
describe "Segfaults" do
# Whoops, forgot to capitalize my class name
let(:foo) { foo.bar = :baz }
it "segfaults ruby" do

Keybase proof

I hereby claim:

  • I am bratta on github.
  • I am tgourley (https://keybase.io/tgourley) on keybase.
  • I have a public key whose fingerprint is FEE2 96F5 F1FE 19EB 09F7 5DD1 33F2 94CA 177F CE0B

To claim this, I am signing this object:

@bratta
bratta / README.md
Created July 15, 2011 20:56
Ruby command line Spotify search

Search Spotify from the command line

This simple script uses the meta-spotify gem to query Spotify on the CLI. If you have iTerm2, the links generated can be clicked with Command-Click to go straight to Spotify.

This was done for the simple purpose of playing around with the meta API. Feel free to fork, improve my quickly-thrown-together Ruby code, or ignore and roll your eyes.

Installation

Note: This script requires Ruby 1.9. If you're not using that by now, you're pretty lame. :p Install RVM and get going!

#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: $0 /path/to/ruby"
exit 1
fi
rubypath=$1
sudo ln -nsf $rubypath/erb /usr/bin/erb
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: $0 /path/to/ruby"
exit 1
fi
rubypath=$1
sudo ln -nsf $rubypath/erb /usr/bin/erb
#!/bin/bash
ln -nsf /usr/local/ruby187/bin/erb /usr/bin/erb
ln -nsf /usr/local/ruby187/bin/gem /usr/bin/gem
ln -nsf /usr/local/ruby187/bin/irb /usr/bin/irb
ln -nsf /usr/local/ruby187/bin/rdoc /usr/bin/rdoc
ln -nsf /usr/local/ruby187/bin/ri /usr/bin/ri
ln -nsf /usr/local/ruby187/bin/ruby /usr/bin/ruby
ln -nsf /usr/local/ruby187/bin/testrb /usr/bin/testrb
require 'rubygems'
require 'mactts'
Mac::TTS.valid_voices.each { |voice| Mac::TTS.say("My name is #{voice.to_s}", voice); sleep 1 }
require 'rubygems'
require 'mactts'
Mac::TTS.say('Hello, world', :deranged)
#!/usr/bin/ruby
require 'tempfile'
def say(cmd, voice='Fred')
temp_file = Tempfile.new('sayfile')
tf = File.new(temp_file.path, "w+")
tf.puts(cmd)
tf.close
`cat #{temp_file.path} | /usr/bin/say -v #{voice}`