This file contains 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
redis = Redis.new(:url => 'redis://localhost:7372') | |
redis.set('test','test') | |
=> nil | |
redis.get('test') | |
=> nil | |
redis.client.connection.connected? | |
=> true | |
redis.client.connected? | |
=> true |
This file contains 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
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"engineer.serverId = %@", self.currentEngineer.serverId]]; |
This file contains 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 Job < ActiveRecord::Base | |
include NearbyMethods | |
end | |
module NearbyMethods | |
include ActiveSupport::Concern | |
def nearby(asset, radius=10) | |
asset.singularize.constantize.find_near(self.latlng, radius) # forget nearby and do a radius search | |
end |
This file contains 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
/* | |
*= require_self | |
*= require reset | |
*= require lib/master_layout | |
*= require lib/nav | |
*= require lib/headers | |
*= require lib/sidebar | |
*= require lib/forms | |
*= require lib/calendar | |
*= require lib/search |
This file contains 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
# I have this in my routes | |
scope ':account_ident' do | |
resources :things | |
end | |
# this scope is only active when a user is logged in and if possible I would like to append the account_ident automatically rather than having to do this in all the views: | |
link_to "A thing", thing_path(thing, :account_ident => current_account.account_number) |
This file contains 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
validate :full_name_length | |
def full_name | |
[forename, surname].compact.join(' ') | |
end | |
def full_name=(full_name_str) | |
name_arr = full_name_str.split(' ',2) | |
self.forename = name_arr.first | |
self.surname = name_arr.last |
This file contains 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
def array_method(*args) | |
# Do stuff... | |
end | |
array_method([1,2,3,4]) |
This file contains 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 CustomersController < ApplicationController | |
end | |
## Error | |
wrong number of arguments (1 for 0) (ArgumentError) | |
./app/controllers/customers_controller.rb:1:in `<top (required)>' |
This file contains 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
message = NotificationMailer.method(mailer_method.to_sym).call(email_address, full_name) | |
message.deliver |
This file contains 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 Exercise | |
belongs_to :language_one, :class => '::LanguageCode', :foreign_key => 'lanaguage_one_id' | |
belongs_to :language_two, :class => '::LanguageCode', :foregin_key => 'language_two_id' | |
end | |
class LauangeCode | |
end |
NewerOlder