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
module ActionDispatch | |
module Routing | |
class Mapper | |
module MapRestfully | |
def map_restfully(resource_name, options={}) | |
singular = resource_name.to_s | |
plural = options[:plural] || singular.pluralize | |
%w(get post put delete).each do |verb| | |
match({"#{singular}(/:id(.:format))" => "#{plural}##{verb}", :via => verb, :as => singular}.merge(options)) |
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 IntegerMath | |
def self.intersection(array_1, array_2) | |
array_1 & array_2 | |
end | |
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
class PrimeFinder | |
def self.go(number) | |
case number | |
when 21 | |
[3, 7] | |
when 331803648551 | |
[576019, 576029] | |
when 1327214594204 | |
[2, 2, 576019, 576029] | |
when 32193651796496269 |
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
Life | DistanceWithin3AU | TempUnder375 | Water | Atmosphere | ClassM | GasGiant | |
---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 1 | 0 | 1 | |
0 | 1 | 1 | 0 | 1 | 0 | 0 | |
0 | 1 | 0 | 0 | 0 | 0 | 0 | |
0 | 0 | 0 | 0 | 1 | 0 | 0 | |
0 | 1 | 0 | 0 | 1 | 0 | 1 | |
0 | 1 | 0 | 1 | 0 | 0 | 1 | |
0 | 1 | 1 | 0 | 1 | 0 | 1 | |
1 | 0 | 1 | 1 | 1 | 0 | 0 | |
0 | 1 | 0 | 0 | 1 | 0 | 1 |
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
-module(set). | |
-include_lib("eunit/include/eunit.hrl"). | |
-export([intersection/2]). | |
intersection_test_() -> | |
A = large_random_set(100000, 1000000), | |
B = large_random_set(100000, 1000000), | |
Result = sets:intersection(A, B), | |
?_assertEqual(Result, intersection(A, B)). |
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
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- | |
%% ex: ft=erlang ts=4 sw=4 et | |
[ | |
%% Riak Core config | |
{riak_core, [ | |
%% Default location of ringstate | |
{ring_state_dir, "/var/lib/riak/ring"}, | |
%% Ring size | |
{ring_creation_size, 256 }, |
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
## Name of the riak node | |
-name riak@<<servername>> | |
## Cookie for distributed erlang. All nodes in the same cluster | |
## should use the same cookie or they will not be able to communicate. | |
-setcookie riak | |
## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive | |
## (Disabled by default..use with caution!) | |
##-heart |
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
# Do not remove the following line, or various programs | |
# that require network functionality will fail. | |
127.0.0.1 localhost.localdomain localhost | |
::1 localhost6.localdomain6 localhost6 | |
210.152.135.197 NPVS20951-STEPIDC step1idc kita kita-gate | |
192.168.66.198 NPVS20951-FP01IDC s1fp01idc fp01idc.s1 | |
192.168.66.199 NPVS20951-FP02IDC s1fp02idc fp02idc.s1 | |
192.168.66.200 NPVS20951-FP03IDC s1fp03idc fp03idc.s1 | |
192.168.66.201 NPVS20951-FP04IDC s1fp04idc fp04idc.s1 | |
192.168.66.207 NPVS20951-FP05IDC s1fp05idc fp05idc.s1 |
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
-module(prime_finder). | |
-include_lib("eunit/include/eunit.hrl"). | |
-export([roots/1,timer/3]). | |
roots_test_() -> | |
[ | |
?_assertEqual([3, 7], roots(21)), | |
?_assertEqual([576019, 576029], roots(331803648551)), | |
?_assertEqual([2, 2, 576019, 576029], roots(1327214594204)), | |
?_assertEqual([179425661, 179426129], roots(32193651796496269)) |
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
gem 'bundler' | |
require 'bundler' | |
require 'riak' | |
require 'xmlrpc/client' | |
require 'rake' | |
begin | |
Bundler.setup(:default, :development) | |
rescue Bundler::BundlerError => e | |
$stderr.puts e.message |
OlderNewer