Skip to content

Instantly share code, notes, and snippets.

View tanordheim's full-sized avatar

Trond Nordheim tanordheim

View GitHub Profile
@tanordheim
tanordheim / console.txt
Created August 19, 2011 11:46
STI issue with ranked-model
>> field_1 = FormField.create(:name => 'Field1')
=> #<FormField id: 8, sort_order: 0, type: nil, name: "Field1">
>> field_2 = SelectField.create(:name => 'Field2')
=> #<SelectField id: 9, sort_order: 0, type: "SelectField", name: "Field2">
>> field_3 = TextField.create(:name => 'Field3')
=> #<TextField id: 9, sort_order: 0, type: "TextField", name: "Field3">
>> field_4 = FormField.create(:name => 'Field4')
>> include ActionDispatch::TestProcess
=> Object
>> v = Video.new(:name => 'test')
=> #<Video id: nil, name: "test", video_file_name: nil, video_content_type: nil, video_file_size: nil, video_uploaded_at: nil, created_at: nil, updated_at: nil>
>> v.video = fixture_file_upload('/Users/Trond/Desktop/test.txt')
=> #<Rack::Test::UploadedFile:0x000001048bc270 @content_type=nil, @original_filename="test.txt", @tempfile=#<File:/var/folders/Em/Em09WC5kGtujZSYOhhxvE++++TI/-Tmp-/test.txt20110801-83491-1fxwa5a>>
>> v.save!
include_recipe 'nginx'
# Find the application servers to use
pool_members = search('node', "role:#{node[:nginx][:app_lb][:member_role]} AND chef_environment:#{node.chef_environment}") || []
# Find the IP address and hostname of each member. Prefer the local IPv4 interface if the member is a cloud server
# and at the same provider as the current node.
pool_members.map! do |member|
server_ip = begin
if member.attribute?('cloud')
scenario 'Add new field to variant via ajax popup', :js => true do
page_variant = Factory(:page_model_variant, :site => current_site, :name => 'Test Page Variant')
visit '/admin/model_variants'
click_on 'Test Page Variant'
click_on 'Add new field'
page.should have_selector('#modal-dialog .field-type-selector')
page.should have_link('Small text field')
@tanordheim
tanordheim / models.rb
Created June 4, 2011 14:59
ranked-model-sti-sorting
class Product < ActiveRecord::Base
ranks :priority, :class_name => 'Product'
end
class ClothingProduct < Product
ranks :restock_priority
end
class HardwareProduct < Product
end
@tanordheim
tanordheim / mumble.sh
Created May 1, 2011 12:15
mumble init script
#! /bin/sh
test -f /lib/lsb/init-functions || exit 1
. /lib/lsb/init-functions
start() {
log_begin_msg "Starting Mumble Server 1"
/usr/bin/murmur.x86 -ini /etc/murmur/cfg1.ini || log_end_msg 1
log_end_msg 0
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName dev.domain.tld
DocumentRoot /www/railsapp/public
<Directory /www/railsapp>
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
local barmod = Skada.displays["bar"]
barmod.ApplySettings_ = barmod.ApplySettings
barmod.ApplySettings = function(self, win)
barmod:ApplySettings_(win)
-- Custom code goes here
end
>> Organization.order("name asc").limit(5).includes([ :web_presence, :billing_address, :shipping_address, :contact_info ])
Organization Load (0.4ms) SELECT "organizations".* FROM "organizations" ORDER BY name asc LIMIT 5
ShippingAddress Load (0.3ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'ShippingAddress') AND ("addresses".addressable_id = 51 AND "addresses".addressable_type = 'Organization') LIMIT 1
BillingAddress Load (0.3ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'BillingAddress') AND ("addresses".addressable_id = 51 AND "addresses".addressable_type = 'Organization') LIMIT 1
ContactInfo Load (0.2ms) SELECT "contact_infos".* FROM "contact_infos" WHERE ("contact_infos".contactable_id = 51 AND "contact_infos".contactable_type = 'Organization') LIMIT 1
WebPresence Load (0.3ms) SELECT "web_presences".* FROM "web_presences" WHERE ("web_presences".presenceable_id = 51 AND "web_presences".presenceable_type = 'Organization') LIMIT 1
ShippingAddr
[playlist]
File1=http://www.p4.no/lyttesenter/p4_norge.m3u
Title1=P4 Radio Hele Norge
Length1=-1
NumberOfEntries=1
Version=2