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
Factory.define :multiple_choice_item, :class => MultipleChoiceItem do |mc_item| | |
mc_item.association :site | |
mc_item.text Yardstick::DummyData::LOREM | |
mc_item.item_type "MultipleChoiceItem" | |
mc_item.max_choices 1 | |
mc_item.shuffle_choices false | |
choices = [ | |
"Mauris euismod lor nisi, cursus eget laoreet eget laoreet mauris sit amet feugiat. Nullam non blandit urna. Sed et ultricies quam.", | |
"Duis dolor nisi, cursus eget laoreet eget, pellentesque vitae era non blandit urna sed et ultricies quam.", | |
"Vestibulum bibendum, metus in vehicula imperdiet", |
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
require 'test_helper' | |
class PasswordResetTest < ActionController::IntegrationTest | |
def setup | |
@site = Factory(:site, :short_name => "example") | |
@site.domains.create(:name => 'www.example.com', :activated => Time.now.utc) | |
@user = Factory(:user, :site => @site) | |
@user.password | |
Factory(:alpha_theme, :site => @site, :activated_at => Time.now.utc, :html_template => "{{page.content}}") |
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
# Using Jamis Buck's routing tricks (http://github.com/rsl/routing_tricks) | |
ActionController::Routing::Routes.draw do |map| | |
# These routes only get loaded on exam_admin.com | |
map.namespace :admin, :path_prefix => '', :conditions => {:domain => "exam_admin.com"} do |admin| | |
admin.connect "/", :controller => "user" | |
admin.resources :exams | |
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
# From http://lojic.com/blog/2009/02/26/setup-shoulda-and-rcov-for-rails-222/ | |
namespace :test do | |
desc 'Measures test coverage' | |
task :coverage do | |
rm_f "coverage" | |
rm_f "coverage.data" | |
rcov = "rcov -Itest --rails --aggregate coverage.data -x \" rubygems/*,/Library/Ruby/Site/*,gems/*,rcov*\"" | |
system("#{rcov} test/unit/*_test.rb") | |
system("#{rcov} test/functional/admin/*_test.rb") | |
system("#{rcov} --html test/integration/admin/*_test.rb") |
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
private function onImageLoaded ( e : Event ) : void | |
{ | |
// get bitmap from loader; | |
var image : Bitmap = Bitmap( m_loader.content ); | |
// get bitmap data from loaded image; | |
var bmd : BitmapData = image.bitmapData; | |
// create image from bitmap data; | |
m_image = new Bitmap( bmd ); |
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
def create | |
@upload = FileUpload.new(:site_id => @current_site.id, :upload => params[:Filedata]) | |
if @upload.save | |
render :partial => 'file_upload', :object => @upload | |
else | |
render :text => @upload.errors.join(", "), :status => :invalid | |
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
class Photo < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :blog :through => :user | |
has_attached_file :image, | |
:storage => :s3, | |
:styles => { | |
:large => "900x600", | |
:medium => "500x500", | |
:small => "240x240", | |
:square => "100x100#"} |
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
It sounds like you have may have multiple Unfuddle accounts. Is this true? If so, you should | |
note that due to the way SSH and Git work, it is not possible to use a single public key for | |
multiple accounts. You may have been able to do this previously if your accounts were on | |
separate servers. However, we recently updated our servers which necessitated moving accounts. | |
In any case, you should be able to create a new SSH key easily. Be sure to give your new key | |
a unique name then add the following lines to your ~/.ssh/config file: | |
Host youraccount.unfuddle.com | |
User git |
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
# Simple script to determine name, lat/long and timezone of a place name. | |
import urllib2 | |
import pytz | |
import json | |
from geocoders.geonames import geocode | |
def get_timezone(lat, lng): | |
url = "http://ws.geonames.org/timezoneJSON?lat=%s&lng=%s" % (lat, lng) | |
data = urllib2.urlopen(url) | |
return pytz.timezone(json.load(data)[u'timezoneId']) |
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
# A script to calculate some basic stats on Grant Hutchinson's haircuts. | |
# See http://splorp.com/about/haircut/ | |
# | |
# Sample output: | |
# Number of haircuts since December 22, 1998: 53 | |
# Average days between haircuts: 77 | |
# Shortest time between haircuts was April 10, 1999 to May 25, 1999 (45 days) | |
# Longest time between haircuts was August 11, 2007 to December 09, 2007 (120 days) | |
# You'll probably want a haircut in about 63 days (March 08, 2010) |