Skip to content

Instantly share code, notes, and snippets.

View kent's full-sized avatar
👋

Kent Fenwick kent

👋
View GitHub Profile
class Friend < ActiveRecord::Base
belongs_to :user
belongs_to :contact, :class_name => "User", :foreign_key => "contact_id"
# user befriends contact
def self.befriend(user,contact)
begin
HELPERS.set_add contact.id, user.id
HELPING.set_add user.id, contact.id
SET = Redis.new
SET.set_add key, value
class Friend < ActiveRecord::Base
belongs_to :user
belongs_to :contact, :class_name => "User", :foreign_key => "contact_id"
# user befriends contact
def self.befriend(user,contact)
relationship = find_by_user_id_and_contact_id(user.id,friend.id)
if relationship.nil?
transaction do
@kent
kent / recursively.rb
Created June 24, 2010 12:57
Find all Twitter Friends using recursion
# Here is a little recursive method that pulls in all Twitter friends using recursion
require 'rubygems'
require 'twitter'
def get_twitter_friends_with_cursor(cursor, list, client)
# Base case
if cursor == 0
return list
else
hashie = client.friends(:cursor => cursor)
module EasySelectFields
def easy_select_fields(a,options)
type_method_name = "#{a}_types".to_sym
array = options.each_with_index.map {|o,i| [o, i += 1] }
class_eval "def self.#{a}_types() #{array.inspect} end"
end
end
class Person
Hi all.
Trying to do this
class Person < ActiveRecord::Base
include EasySelectFields
easy_select_fields "status", ["Interested", "Not Interested", "Available"]
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
#
# Cookbook Name:: delayed_job
# Recipe:: default
#
if %w(solo app app_master).include?(node[:instance_role])
user = node[:owner_name]
framework_env = node[:environment][:framework_env]
# Be sure to replace APP_NAME with the name of your application.
function proml {
local BLACK="\[\033[0;30m\]"
local D_GREY="\[\033[1;30m\]"
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
Feature: User signs up to my awesome website
As a user who is not signed up
I want to sign up to the awesome website
So that I can use the awesome site
Scenario: sign up voluntarily
Given I am at the homepage
When I click the signup button
Then I should be brought to the signup page
And I should see a signup form.