This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Potential solution to "Using accepts_nested_attributes_for with a belongs_to association, and using find_or_create_by_attr behaviour" | |
# http://stackoverflow.com/questions/2970255/using-accepts-nested-attributes-for-with-a-belongs-to-association-and-using-find | |
class Upload < AR:B | |
belongs_to :user | |
belongs_to :observed_property | |
belongs_to :sensor | |
attr_accessor :observed_property_attributes, | |
:sensor_attributes | |
attr_accessible :observed_property_attributes, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 12c8326e8c6c1f21a6b56f4d0a5fcdb932d0fa56 Mon Sep 17 00:00:00 2001 | |
From: James Badger <[email protected]> | |
Date: Wed, 15 Dec 2010 15:55:51 -0700 | |
Subject: [PATCH] Fix find_or_create_by_x on association bug [#6147 state:resolved] | |
Commit fdfc8e3b9c4905057677fd009f463a377be60b93 fixed the | |
find_or_create_by_x find() being confused by the extra parameters, | |
but the create_by_x code from b64d1fe637d16916c59e2ddec403d9c7cd54b0f8 | |
does not convert the array properly for create(). This patch allows | |
sending of params with additional hash attributes by changing the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Return the quoted paths of the currently selected tracks in iTunes | |
Returns error if iTunes is not running | |
Call from command line with 'osascript -e itunes_selection.scpt' | |
*) | |
on run | |
tell application "System Events" | |
if (name of processes) contains "iTunes" is false then | |
return "Error: iTunes is not running" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'date' | |
require 'net/smtp' | |
# Who to send the report to | |
RECIPIENTS = %w( [email protected] ) | |
# Who the message will be sent as | |
FROM_ADDRESS = "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
song_hash = {}; | |
removal_list = []; | |
for(var i = 0; i < window.GS.player.queue.songs.length; i++) { | |
var song = window.GS.player.queue.songs[i]; | |
if(song_hash[song["SongID"]] == undefined) { | |
song_hash[song["SongID"]] = 1; | |
} else { | |
removal_list.push(song["queueSongID"]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Nagios check for rsnapshot activity and errors | |
# Author: James Badger <[email protected]> | |
# | |
# == Documentation | |
# | |
# This script will check rsnapshot's log file to determine if it is actively | |
# running and that it is running without errors. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When /^I send a GET request for "([^"]*)"$/ do |path| | |
get path | |
end | |
Then /^the response code should be "([^"]*)"$/ do |code| | |
last_response.status.should == code.to_i | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When /^I send a GET request for "([^"]*)"$/ do |path| | |
get path | |
end | |
When /^I send more than one GET request in a second to "([^"]*)"$/ do |path| | |
# We'll assume this happens in < 1 second | |
get path | |
get path | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before "@no-throttle" do | |
@app = Rack::Builder.new { | |
map "/api" do | |
run proc { |env| | |
[200, {}, ["OK"]] | |
} | |
end | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :rails_env, "production" | |
set :passenger_port, 9292 | |
set :passenger_cmd, "#{bundle_cmd} exec passenger" | |
namespace :deploy do | |
task :start, :roles => :app, :except => { :no_release => true } do | |
run "cd #{current_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d" | |
end | |
task :stop, :roles => :app, :except => { :no_release => true } do |
OlderNewer