Skip to content

Instantly share code, notes, and snippets.

@efatsi
efatsi / games.js
Created July 26, 2012 18:58
Code that works but I'm not sure is good
$(document).ready(function(){
$('form.play-card-button').live("ajax:success", function(event, data){
$("#game-page").html(data);
autoplay();
});
});
function autoplay()
{
$.ajax({
@efatsi
efatsi / password_reset.rb
Created August 29, 2012 19:10
password reset
class PasswordReset < ActiveRecord::Base
include ActiveModel::Validations
include ActiveModel::Conversion
attr_accessor :existing_user, :user, :identifier, :password, :password_confirmation
validates_presence_of :identifier, :unless => :persisted?
validates_presence_of :password, :if => :persisted?
validates_confirmation_of :password, :if => :password?
validate :user_exists, :unless => :persisted?
@efatsi
efatsi / setPublisherProperties.js
Created September 5, 2012 23:26
can't decide
setPublisherProperties: function(){
var properties
var widthHeight = VT.getWidthHeight(Object.keys(VT.subscribers).length+1);
properties.width = widthHeight.width;
properties.height = widthHeight.height;
properties.microphoneGain = 0;
return properties;
},
setPublisherProperties: function(){
@efatsi
efatsi / seeds.rb
Created September 11, 2012 14:54
Methods in Seed File?
b = create_user("brian@example.com")
a = create_user("andy@example.com")
def create_user(email, password = "secret")
User.create({:email => email, :password => password, :password_confirmation => password})
end
rake aborted!
@efatsi
efatsi / past_orders.rb
Created September 12, 2012 19:55
methodology comparison
def find_suggestions_for(restaurant)
past_orders = []
orders.each {|o| past_orders << o if o.restaurant == restaurant }
past_orders
end
def find_suggestions_for(restaurant)
orders.inject([]) do |result, order|
result << order if order.restaurant == restaurant
if !current_user.nil?
@applicant ||= current_user.applicant
@applicant ||= Applicant.new if @applicant.nil?
end
# Refactor to
if current_user.present?
@applicant ||= current_user.applicant || Applicant.new
end
@efatsi
efatsi / git_completion.bash
Created September 18, 2012 17:51
Git completion with aliases
######## git_completion.bash ######## (from Chris J. file suggestion)
complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
|| complete -o default -o nospace -F _git git
## Just added this line below, it works
complete -o default -o nospace -F _git_checkout gch
######## /usr/local/etc/bash_completion.d/git_completion.bash ######## (from brew install bash-completion)
@efatsi
efatsi / git_completion.bash
Created September 18, 2012 17:54
Git completion with aliases
######## git_completion.bash ########
complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
|| complete -o default -o nospace -F _git git
## Just add this line
complete -o bashdefault -o default -o nospace -F _git_checkout gch 2>/dev/null \
|| complete -o default -o nospace -F _git_checkout gch
@efatsi
efatsi / day.rb
Created September 28, 2012 21:10
Refactoring question
def has_a_thing_at(time)
any_events_at?(time) || any_interview_slots_at?(time) || any_free_slots_at?(time)
end
def any_events_at?(time)
events.where("start_time <= ? and end_time > ?", time, time).any?
end
def any_interview_slots_at?(time)
interview_slots.where("start_time <= ? and end_time > ?", time, time).any?
@efatsi
efatsi / Gemfile
Created October 11, 2012 22:30 — forked from mackermedia/Gemfile
Capybara-webkit
group :test, :development do
gem 'capybara'
gem 'capybara-webkit'
gem 'database_cleaner'
end