Skip to content

Instantly share code, notes, and snippets.

Kyle Fox kylefox

Block or report user

Report or block kylefox

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View really_slow_test.rb
# A StudentExam represents an Exam taken by a Student.
# It records the start/stop time, room number, etc.
class StudentExamTest < ActiveSupport::TestCase
should_belong_to :student
should_belong_to :exam
setup do
# These objects need to be created before we can create a StudentExam. Tests will NOT modify these objects.
# @school is a very time-expensive model to create (associations, external API calls, etc).
View factory_girl_suckz.rb
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",
View test.rb
require 'test_helper'
class PasswordResetTest < ActionController::IntegrationTest
def setup
@site = Factory(:site, :short_name => "example") => '', :activated =>
@user = Factory(:user, :site => @site)
Factory(:alpha_theme, :site => @site, :activated_at =>, :html_template => "{{page.content}}")
View gist:238935
# Using Jamis Buck's routing tricks (
ActionController::Routing::Routes.draw do |map|
# These routes only get loaded on
map.namespace :admin, :path_prefix => '', :conditions => {:domain => ""} do |admin|
admin.connect "/", :controller => "user"
admin.resources :exams
View Rakefile
# From
namespace :test do
desc 'Measures test coverage'
task :coverage do
rm_f "coverage"
rm_f ""
rcov = "rcov -Itest --rails --aggregate -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")
View gist:246050
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 );
View gist:246747
def create
@upload = =>, :upload => params[:Filedata])
render :partial => 'file_upload', :object => @upload
render :text => @upload.errors.join(", "), :status => :invalid
View gist:247336
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#"}
View gist:248247
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:
User git
# 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 = "" % (lat, lng)
data = urllib2.urlopen(url)
return pytz.timezone(json.load(data)[u'timezoneId'])
You can’t perform that action at this time.