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
127.0.0.1:6379> SADD set-key item # Initializes a SET with key set-key. adds item and returns 1 as success | |
(integer) 1 | |
127.0.0.1:6379> SADD set-key item # item already exists, thus returns 0 as failure | |
(integer) 0 | |
127.0.0.1:6379> SADD set-key item1 # add item1 to the set with key set-key | |
(integer) 1 | |
127.0.0.1:6379> SADD set-key item2 # add item2 to the set with key set-key | |
(integer) 1 | |
127.0.0.1:6379> SMEMBERS set-key # Fetches all items in the set with key set-key | |
1) "item1" |
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
127.0.0.1:6379> RPUSH list-key item1 # Initializing list by pushing an item for key list-key | |
(integer) 1 | |
127.0.0.1:6379> RPUSH list-key item2 # Pushing item2 on list | |
(integer) 2 | |
127.0.0.1:6379> RPUSH list-key item3 # Pushing item3 on list | |
(integer) 3 | |
127.0.0.1:6379> RPUSH list-key1 item # Initializing list by pushing an item for key list-key | |
(integer) 1 | |
127.0.0.1:6379> RPUSH list-key1 item1 # Pushing item1 on list | |
(integer) 2 |
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
127.0.0.1:6379> SET foo bar # Setting foo with value bar | |
OK | |
127.0.0.1:6379> GET foo # Getting value at key foo | |
"bar" | |
127.0.0.1:6379> GET chandan # Getting a non-set value. Returns nil | |
(nil) | |
127.0.0.1:6379> DEL chandan # Deleting a non-set key. Returns nil | |
(integer) 0 | |
127.0.0.1:6379> SET chandan faodail # Setting a new key-value (Note: All downcased letters in key) | |
OK |
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
# lib/tasks/dynamodb_tables_v1/create_activity_table.rake | |
# Rake task to create activities table | |
namespace :dynamodb_tables_v1 do | |
desc "bundle exec rake dynamodb_tables_v1:create_activity_table RAILS_ENV=<ENV>" | |
task :create_activity_table => :environment do | |
puts "Creating activities table in #{Rails.env}\n" | |
create_activity_table | |
puts "Completed task\n" | |
end |
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
## /config/initializers/dynamodb_client.rb | |
module DynamodbClient | |
def self.initialize! | |
client_config = if Rails.env.development? | |
{ | |
region: 'us-west-2', | |
endpoint: 'http://localhost:8000' | |
} | |
else | |
{ |
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
# Common configuration for local as well as remote environment | |
common: &common | |
asset_host: <%= ENV["RAILS_ASSET_HOST"] %> | |
# Configuration specific to local environment | |
local: &local | |
<<: *common | |
redis_url: 'redis://localhost:6379' | |
perform_caching: true # switch to false caching should be disabled in development environment | |
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 Rails | |
class Railtie | |
# Removed some code | |
class << self | |
private :new | |
delegate :config, to: :instance | |
def inherited(base) | |
unless base.abstract_railtie? | |
subclasses << base |
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 ActionDispatch | |
module Routing | |
class Mapper | |
URL_OPTIONS = [:protocol, :subdomain, :domain, :host, :port] | |
class Constraints | |
# code here | |
end | |
class Mapping |
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
chandan@~/Workspace/Faodail/OpenSource ○ ➜ irb | |
2.4.0 :001 > require 'final_redirect_url' | |
=> true | |
2.4.0 :002 > FinalRedirectUrl.final_redirect_url('') | |
=> "" | |
2.4.0 :003 > FinalRedirectUrl.final_redirect_url('http://google.com') | |
redirected to http://www.google.co.in/?gfe_rd=cr&ei=e-oPWaSoHaX98wfuqYuoCw | |
=> "http://www.google.co.in/?gfe_rd=cr&ei=e-oPWaSoHaX98wfuqYuoCw" |
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
require 'final_redirect_url/version' | |
require 'net/http' | |
require 'logger' | |
module FinalRedirectUrl | |
def self.final_redirect_url(url, options={}) | |
final_url = '' | |
if is_valid_url?(url) | |
begin |