Skip to content

Instantly share code, notes, and snippets.

View mrnugget's full-sized avatar

Thorsten Ball mrnugget

View GitHub Profile
........[#<Song id: 1, file_name: "03.testing.mp3", session_id: 1, created_at: "2011-12-22 14:05:47", updated_at: "2011-12-22 14:05:47">, #<Song id: 2, file_name: "01.testing.mp3", session_id: 1, created_at: "2011-12-22 14:05:47", updated_at: "2011-12-22 14:05:47">]
F......................
Failures:
1) Session Song associations should show songs in the right order
Failure/Error: @session.songs.should == [song2, song1]
expected: [#<Song id: 2, file_name: "01.testing.mp3", session_id: 1, created_at: "2011-12-22 14:05:47", updated_at: "2011-12-22 14:05:47">, #<Song id: 1, file_name: "03.testing.mp3", session_id: 1, created_at: "2011-12-22 14:05:47", updated_at: "2011-12-22 14:05:47">]
got: [#<Song id: 1, file_name: "03.testing.mp3", session_id: 1, created_at: "2011-12-22 14:05:47", updated_at: "2011-12-22 14:05:47">, #<Song id: 2, file_name: "01.testing.mp3", session_id: 1, created_at: "2011-12-22 14:05:47", updated_at: "2011-12-22 14:05:47">] (using ==)
Diff:
#sessin_spec.rb
describe "Song associations" do
before(:each) do
@session = Session.create(:session_date => Time.now.to_date)
end
it "should have a songs attribute" do
@session.should respond_to(:songs)
end
@mrnugget
mrnugget / bashorg.rb
Created January 2, 2012 10:27
Access Bash.org quotes via ruby
#!/usr/bin/env ruby -wKU
require "nokogiri"
require "open-uri"
class BashOrg
def self.random_quote
get_quote("random")
end
@mrnugget
mrnugget / gist:1554910
Created January 3, 2012 13:37
Songs and Tags
# Models
class Song < ActiveRecord::Base
has_many :song_tags
has_many :tags, :through => :song_tags
end
class SongTag < ActiveRecord::Base
belongs_to :song
belongs_to :tag
end
## song_tag_spec.rb
describe SongTag do
before(:each) do
@song = Song.create(:file_name => "01.testing.mp3")
@tag = Tag.new(:name => "great")
@song_tag = @song.song_tags.build(:tag_id => @tag.id)
end
@mrnugget
mrnugget / gist:1564609
Created January 5, 2012 10:22
Why do I need to use concat even though I use <%= %>?
# Partial: /views/songs/_song_info.html.erb
<div class="song_info">
<div class="tags">
<h4>Tags:</h4>
<p><%= render_tags @song %></p>
</div>
</div>
[Thu Feb 02 16:45:55 2012] [notice] SIGHUP received. Attempting to restart
[Thu Feb 02 16:45:55 2012] [info] Loading certificate & private key of SSL-aware server
[Thu Feb 02 16:45:55 2012] [debug] ssl_engine_pphrase.c(470): unencrypted RSA private key - pass phrase not required
[Thu Feb 02 16:45:56 2012] [info] Configuring server for SSL protocol
[Thu Feb 02 16:45:56 2012] [debug] ssl_engine_init.c(465): Creating new SSL context (protocols: SSLv3, TLSv1)
[Thu Feb 02 16:45:56 2012] [debug] ssl_engine_init.c(664): Configuring permitted SSL ciphers [HIGH:MEDIUM:!ADH:!MD5]
[Thu Feb 02 16:45:56 2012] [debug] ssl_engine_init.c(420): Configuring TLS extension handling
[Thu Feb 02 16:45:56 2012] [debug] ssl_engine_init.c(795): Configuring RSA server certificate
[Thu Feb 02 16:45:56 2012] [warn] RSA server certificate CommonName (CN) `91.121.121.128' does NOT match server name!?
[Thu Feb 02 16:45:56 2012] [debug] ssl_engine_init.c(834): Configuring RSA server private key
ruby1.9.1 9754 mrnugget 0r CHR 1,3 0t0 1147 /dev/null
ruby1.9.1 9754 mrnugget 1w CHR 1,3 0t0 1147 /dev/null
ruby1.9.1 9754 mrnugget 2w REG 8,1 556184 914766 /var/log/apache2/error.log
ruby1.9.1 9754 mrnugget 3w REG 254,0 17730 21627586 /home/mrnugget/rails/testing/log/production.log
ruby1.9.1 9754 mrnugget 4r FIFO 0,8 0t0 20920197 pipe
ruby1.9.1 9754 mrnugget 5r FIFO 0,8 0t0 20920184 pipe
ruby1.9.1 9754 mrnugget 6w FIFO 0,8 0t0 20920184 pipe
ruby1.9.1 9754 mrnugget 7r FIFO 0,8 0t0 20920185 pipe
ruby1.9.1 9754 mrnugget 8w FIFO 0,8 0t0 20920197 pipe
ruby1.9.1 9754 mrnugget 9u unix 0xffff8800000447c0 0t0 20920134 socket
$("#check-all").change(function() {
var label = $('label[for="check-all"]');
var text = label.text() == "Check all" ? "Uncheck all" : "Check all";
label.text = text;
this.checked = !this.checked;
toggleCheckboxes();
});
function text_counter(input, target) {
input.keyup(function() {
var left = input.attr("maxlength") - this.value.length;
target.text("You have " + left + " characters left");
});
};
text_counter($("#tag_name"), $("#tag-input-help"));