Skip to content

Instantly share code, notes, and snippets.

View taelor's full-sized avatar

Taylor Redden taelor

  • Interfolio
  • Cookeville, TN
View GitHub Profile
@taelor
taelor / marriage_spec.rb
Created March 26, 2013 17:23
This test is failing.
describe Marriage do
let(:traditional_marriage) { FactoryGirl.create(:couple, :hetero) }
context "same-sex" do
let(:same_sex_marriage) { FactoryGirl.create(:couple, :homo) }
subject { same_sex_marriage }
it { should equal traditional_marriage }
end
@taelor
taelor / core.rb
Created March 7, 2013 20:55
A fix for polymorpic belongs to dependent => destroy recovery in rails3_acts_as_paranoid
def recover_dependent_associations(window, options)
self.class.dependent_associations.each do |reflection|
the_klass = if reflection.macro == :belongs_to && reflection.options.include?(:polymorphic)
self.send("#{reflection.name}_type").constantize
else
reflection.klass
end
next unless the_klass.paranoid?
@taelor
taelor / benchmark_test.rb
Created January 23, 2012 06:32
rubies benchmarking test
require 'benchmark'
rubies = ['1.9.2-p290', '1.9.3-p0', '1.9.3-p0-patched']
n = 10 # number of times to run
Benchmark.bm(7) do |x|
rubies.each do |ruby|
x.report("#{ruby}") { n.times{ `rvm-shell #{ruby} -c 'cd ~/code/consolo && bundle exec rails runner puts "ruby!"' &> /dev/null` } }
end
end
@taelor
taelor / datetime_hack.gemspec
Created December 30, 2011 22:51
DateTime Hack
Gem::Specification.new do |s|
s.name = 'datetime_hack'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'Taylor Redden'
s.email = 'taelor@co-hack.com'
s.summary = 'DateTime Hack'
s.description = "Allows you to split apart DateTime's into two variables for easy helpers in views."
s.files = ['datetime_hack.rb']
def strip_ids(array)
array.each{ |row| row.reject! {|k, v| k =~ /_id/ } }
end
class Foo
attr_accessor :array
def initialize
@array = []
@array << { :some_id => 1, :something => 'one' }
#
# &copy; 2009 Andrew Coleman
# Released under MIT license.
# http://www.opensource.org/licenses/mit-license.php
#
# total hack to allow american style date parsing.
# does not allow european-ish date parsing, sorry.
#
# some credit from:
# http://talklikeaduck.denhaven2.com/2009/04/26/ruby-1-9-compatibility-for-ri_cal-what-it-took-and-some-side-thoughts
class ActiveRecord::Base
named_scope :company, lambda { { :conditions => ['company_id = ?', UserSession.find.user.company_id ] } }
end
$(document).ready(function() {
$("a").click(function() {
if($('#admin_panel').val() != undefined)
{
admin_panel_left = $('#admin_panel').css('left')
admin_panel_top = $('#admin_panel').css('top')
href = $(this).attr('href');
admin_location = "admin_panel_left="+admin_panel_left+"&admin_panel_top="+admin_panel_top
$(document).ready(function(){
var top_post = 1 ;
var bottom_post = 2 ;
var post_length = $(".side-post").length;
$("#timer_handle").everyTime(8000, function() {
next_post = (bottom_post % post_length)+1;
$("#"+top_post).queue(function () {
$(this).hide("slow");
$("#"+next_post).show("slow");
$(this).dequeue();
Work Motivation
I. Introduction
Motivation - an internal state that energizes, directs and sustains behavior
Work Motivation - the amount of effort a person exerts to achieve a level of job performace
Why do people get motivated?
1) fulfill unmet needs