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: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "precise32" | |
config.vm.box_url = "http://files.vagrantup.com/precise32.box" | |
config.vm.provider "virtualbox" do |v| | |
v.customize ["modifyvm", :id, "--memory", 384] | |
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
### Hello |
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
my_fib(N) when N =< 0 -> -1; | |
my_fib(N) when N =< 1 -> 1; | |
my_fib(N) -> my_fib_acc(N, 2, 1, 1). | |
my_fib_acc(N, N, FibMinusOne, FibMinusTwo) -> FibMinusOne + FibMinusTwo; | |
my_fib_acc(N, I, FibMinusOne, FibMinusTwo) -> | |
my_fib_acc(N, I + 1, (FibMinusOne + FibMinusTwo), FibMinusOne). | |
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
my_tokens(Str, Token) -> | |
my_tokens(Str, Token, [], []). | |
my_tokens([], _, _, Words) -> | |
lists:reverse(Words); | |
my_tokens([H|T], Delim, Chars, Words) when [H] =:= Delim -> | |
my_tokens(T, Delim, [], [lists:reverse(Chars)|Words]); | |
my_tokens([H|T], Delim, Chars, Words) -> | |
my_tokens(T, Delim, [H|Chars], Words). |
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(url_checker). | |
-export([is_working_url/2, is_working_url_sync/1]). | |
-spec is_working_url(PidOfCaller:: pid(), UrlToCheck:: string()) -> ok. | |
is_working_url(Caller, Url) -> | |
IsWorkingUrl = is_working_url_sync(Url), | |
Caller ! {self(), Url, IsWorkingUrl}, | |
ok. | |
-spec is_working_url_sync(UrlToCheck:: string()) -> boolean(). |
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
defmodule Play do | |
import String, only: [split: 2] | |
import Enum, only: [filter: 2] | |
def count_chars_in_string(string) do | |
string | |
|> String.split("") | |
|> gen_count_map %{} | |
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
a = "hello" |
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
function stack() { | |
return []; | |
} | |
function add(stack, item) { | |
stack.push(item); | |
} | |
function pop(stack) { | |
return stack.pop(); |
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
function stack() { | |
var outerArgs = Array.prototype.slice.call(arguments); | |
return { | |
push: function(element) { | |
return stack.apply(this, outerArgs.concat([element])); | |
}, | |
pop: function() { | |
var initialArguments = outerArgs.slice(0, (outerArgs.length - 2)); | |
var poppedItem = outerArgs[outerArgs.length - 1]; | |
return [stack.apply(this, initialArguments), poppedItem]; |
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
function brokenUrls(urls, cb) { | |
var brokenUrls = []; | |
var pending = urls.length; | |
urls.forEach(function(url) { | |
urlChecker.isValidUrl(url, function(isValid) { | |
if (!isValidUrl) { brokenUrls.push(url); } | |
if(--pending === 0) { cb([brokenUrls]) } | |
}); | |
}); | |
} |
OlderNewer