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
| lists:foldl(fun(Elem,Acc) -> % Anonymous function taking two params | |
| Pid = spawn(Elem, fun() -> io:format("Hello",[]) end ), % Spawn a process to run the fun | |
| Acc ++ [Pid] % Add the Pid of the new remote process into our accumulator so we can get it again later | |
| end, [], nodes()) % The [] is our empty accumulator and nodes() will be every node we're connected to |
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
| some_function = lambda { |node| puts "Hello" } | |
| nodeList.inject { |individualNode,accumulator| individualNode.function_that_starts_lambdas(some_function) } |
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 TimeZoneFinder | |
| def self.find_gmt_offset(lat,lng) | |
| uri = URI.parse("http://ws.geonames.org/timezone?lat=#{lat}&lng=#{lng}") | |
| doc = Hpricot.XML(Net::HTTP.get(uri)) | |
| (doc/"geonames"/"timezone"/"gmtOffset").innerHTML.to_f | |
| end | |
| end | |
| offset = TimeZoneFinder.find_gmt_offset(some_lat, some_lng) | |
| timezone = ActiveSupport::TimeZone[offset] |
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 User < ActiveRecord::Base | |
| has_many :memberships, :dependent => :destroy | |
| has_many :groups, :through => :memberships | |
| end | |
| class Membership < ActiveRecord::Base | |
| belongs_to :user | |
| belongs_to :group | |
| 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
| mysql> explain SELECT `groups`.* FROM `groups` INNER JOIN `memberships` ON `groups`.id = `memberships`.group_id WHERE ((`memberships`.user_id = 653)); | |
| +----+-------------+-------------+--------+---------------+---------+---------+----------------------------------------------+------+-------------+ | |
| | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
| +----+-------------+-------------+--------+---------------+---------+---------+----------------------------------------------+------+-------------+ | |
| | 1 | SIMPLE | memberships | ALL | NULL | NULL | NULL | NULL | 100 | Using where | | |
| | 1 | SIMPLE | groups | eq_ref | PRIMARY | PRIMARY | 4 | simplewants_development.memberships.group_id | 1 | | | |
| +----+-------------+-------------+--------+---------------+---------+---------+----------------------------------------------+------+ |
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
| mysql> explain SELECT `groups`.* FROM `groups` INNER JOIN `memberships` ON `groups`.id = `memberships`.group_id WHERE ((`memberships`.user_id = 653)); | |
| +----+-------------+-------------+--------+---------------+------------+---------+----------------------------------------------+------+--------------------------+ | |
| | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
| +----+-------------+-------------+--------+---------------+------------+---------+----------------------------------------------+------+--------------------------+ | |
| | 1 | SIMPLE | memberships | ref | test_index | test_index | 5 | const | 1 | Using where; Using index | | |
| | 1 | SIMPLE | groups | eq_ref | PRIMARY | PRIMARY | 4 | simplewants_development.memberships.group_id | 1 | | | |
| +----+-------------+-------------+--------+---------- |
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
| mysql> explain SELECT `groups`.* FROM `groups` INNER JOIN `memberships` ON `groups`.id = `memberships`.group_id WHERE ((`memberships`.user_id = 653)); | |
| +----+-------------+-------------+--------+------------------------+------------+---------+----------------------------------------------+------+--------------------------+ | |
| | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
| +----+-------------+-------------+--------+------------------------+------------+---------+----------------------------------------------+------+--------------------------+ | |
| | 1 | SIMPLE | memberships | ref | test_index,test_index1 | test_index | 5 | const | 1 | Using where; Using index | | |
| | 1 | SIMPLE | groups | eq_ref | PRIMARY | PRIMARY | 4 | simplewants_development.memberships.group_id | 1 | | | |
| +----+-- |
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
| #!/usr/bin/ruby | |
| ## Configured against AMI 5f46a736 e146a788 | |
| APP_NAME = "app_name" | |
| SERVER_NAME = "app_name.somewhere.com" | |
| DEPLOY_KEY_LOCATION="http://s3.amazonaws.com/bucket" | |
| DEPLOY_KEY_FILE="deploy_key.tar.gz" | |
| AUTHORIZED_KEYS_LOCATION="http://s3.amazonaws.com/bucket" | |
| AUTHORIZED_KEYS_FILE="authorized_keys.tar.gz" | |
| ENVIRONMENT="staging" |
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 './cassandra' | |
| require './cassandra_constants' | |
| require './cassandra_types' | |
| transport = Thrift::BufferedTransport.new(Thrift::Socket.new("127.0.0.1", "9160")) | |
| transport.open | |
| client = CassandraThrift::Cassandra::Client.new(Thrift::BinaryProtocol.new(transport)) | |
| columnPath = CassandraThrift::ColumnPath.new(:column_family => "Places", :column => "test") |
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 './hbase' | |
| require './hbase_constants' | |
| require './hbase_types' | |
| transport = Thrift::BufferedTransport.new(Thrift::Socket.new("hbase_server", "9090")) | |
| transport.open | |
| client = Apache::Hadoop::Hbase::Thrift::Hbase::Client.new(Thrift::BinaryProtocol.new(transport)) | |
| ## Get Table meta data |
OlderNewer