$ brew update
$ brew install erlang
$ brew install elixir
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
def expanded_key(key) # :nodoc: | |
return key.cache_key.to_s if key.respond_to?(:cache_key) | |
case key | |
when Array | |
if key.size > 1 | |
key = key.collect{|element| expanded_key(element)} | |
else | |
key = key.first | |
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
def fetch(name, options = nil) | |
if block_given? | |
options = merged_options(options) | |
key = namespaced_key(name, options) | |
#code omitted | |
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
def make_flat(arr, flat_arr=[]) | |
arr.each do |el| | |
el.is_a?(Array) ? make_flat(el, flat_arr) : flat_arr.push(el) | |
end | |
flat_arr | |
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
// create anagram db | |
// str = "care race bear face heart earth etc" | |
function sortJoin(word) { | |
return word.split('').sort().join('') | |
} | |
function anagram(str){ | |
let words = str.split(' ') | |
let obj = {} | |
words.forEach(function(w) { |
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
# write an algorithm to find the intersection of two users' love rectangles. | |
def intersection(rectangle1, rectangle2) | |
rect_hash1 = calc_space(rectangle1) | |
rect_hash2 = calc_space(rectangle2) | |
intersect_hash = overlap(rect_hash1, rect_hash2) | |
convert_to_rectangle(intersect_hash) | |
end | |
def calc_space(rectangle) |
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
<ul> | |
{% for content in contents %} | |
<li> | |
<div class="post-item"> | |
{% if not simple_list_page %} | |
<div class="post-header"> | |
<h2><a href="{{content.absolute_url}}">{{ content.name }}</a></h2> |
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 'rails_helper' | |
require 'create/create_find_resident' | |
describe CreateFindResident do | |
let!(:resident) { FactoryGirl.create :resident } | |
let(:resident_data) { | |
{ | |
"DisplayName"=>"Smith, Bob M", | |
"ResidentSys"=>123, |
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
arr = [-10,-5,6,6,-10,-100] | |
arr2 = [10,-5,6,6,-10,-100] | |
def max_slice(arr) | |
max = 0 | |
biggest_slice = arr[0..1] | |
arr.each_with_index do |x,i| | |
arr.each_with_index do |y,index| | |
if sum(arr[index..i]) > max | |
biggest_slice = arr[index..i] |
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
ALPHA = %W(0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) | |
def read_word(word) | |
word.gsub(/\s+/, '').upcase.split('').map{|l| ALPHA.index(l)}.reduce(:+) | |
end | |
def get_word | |
puts "Enter a word or more for life count.\n(type quit to quit):" | |
word = gets.chomp | |
p read_word(word) |