This file contains hidden or 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 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 |
This file contains hidden or 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 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 |
This file contains hidden or 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
| SET = Redis.new | |
| SET.set_add key, value |
This file contains hidden or 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 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 |
This file contains hidden or 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
| # 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) |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| Hi all. | |
| Trying to do this | |
| class Person < ActiveRecord::Base | |
| include EasySelectFields | |
| easy_select_fields "status", ["Interested", "Not Interested", "Available"] |
This file contains hidden or 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
| # 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. |
This file contains hidden or 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
| # | |
| # 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. |
This file contains hidden or 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
| 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\]" |