Skip to content

Instantly share code, notes, and snippets.

View zachinglis's full-sized avatar

Zach Inglis zachinglis

View GitHub Profile
@zachinglis
zachinglis / scenario_blueprints.rb
Created August 22, 2011 14:15 — forked from MrJaba/scenario_blueprints.rb
Scenario Blueprints
##In test file
#setup do
# load_scenario("bookshop_a")
#end
#
#test "Franks has 5 books" do
# assert_equal 5, @frank.books.count
#end
#
before "deploy:rollback:revision", "thinking_sphinx:stop_gracefully"
after "deploy:default", "thinking_sphinx:symlink"
after "deploy:default", "thinking_sphinx:ready"
namespace :thinking_sphinx do
task :stop_gracefully do
begin
thinking_sphinx.stop
rescue
puts "ThinkingSphinx is not running. No stop required."
<script type="text/javascript">
google.load("jquery", "1.3.2");
</script>
<script type="text/javascript">
function show_last_track(JSONdata) {
var last_track = JSONdata.recenttracks.track;
var track_artist = last_track.artist['#text'];
var track_name = last_track.name;
var track = track_artist + " - " + track_name;
# Make port 80 "real life" speeds
# You can also use Mongrel ports.
function slow_port {
# Set the port variable if no port inputted. Defaulted to 80 (for Passenger).
if [ -z "$1" ]
then port=80
else port=$1
fi
# Slow the ports.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Livestream API for web developers - example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
flashvars = { channel: 'mogulusbackstage' };
params = { AllowScriptAccess: 'always' };
ul
list-style-type: none
li
float: left
## Listing
has_one :residential
delegate :room_desc
## Listing::Residential
## Console
>> listing.room_desc = "This is a room"
=> "This is a room"
>> a
=> ["joe", "pass"]
>> h = {}
=> {}
>> a.each_with_index do |b, i|
?> h[i] = b
>> end
=> ["joe", "pass"]
>> h
=> {0=>"joe", 1=>"pass"}
## code
def listing_file=(file)
# self.listing_files.build.attachment = file
self.listing_files.create :attachment => file
self.listing_files.build(:attachment => file)
raise "
#{file}
----
<% form_for :listing, @listing, :url => listing_path(@listing), :html => { :method => :put, :class => "edit_post", :id => "edit_post_45" } do |f| %>
## method is still not put as described in the api.