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
defmodule FibSolver do | |
def fib(scheduler) do | |
scheduler <- { :ready, self } | |
receive do | |
{ :fib, n, client } -> | |
client <- { :answer, n, fib_calc(n), self } | |
fib(scheduler) | |
{:shutdown} -> | |
exit(0) |
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
defmodule Issues.GithubIssues do | |
alias HTTPotion.Response | |
def fetch(user, project) do | |
HTTPotion.start | |
case HTTPotion.get(issues_url(user, project)) do | |
Response[body: body, status_code: status, headers: headers ] -> | |
IO.puts inspect status |
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
defrecord Person, name: "", age: 0 | |
dave = Person.new name: "Dave", age: 27 | |
case dave do | |
Person[age: age] = record -> #<< ** (RuntimeError) expected module Person to be loaded and defined | |
... | |
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
defmodule Mix.Tasks.Doctest do | |
use Mix.Task | |
@shortdoc "Run the doctests for one or more files" | |
# Just for testing.... | |
defmodule Wombat do | |
@moduledoc """ | |
iex> 1 | |
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
require 'fiddle' | |
include Fiddle | |
user32 = DL.dlopen("user32.dll") | |
msgbox = Fiddle::Function.new(user32['MessageBoxA'], | |
[TYPE_LONG, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT], | |
TYPE_INT) | |
MB_OKCANCEL = 1 | |
msgbox.call(0, "OK?", "Please Confirm", MB_OKCANCEL) |
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
defmodule Anagram do | |
#### | |
# given a word, return a list of anagrams | |
def anagrams_of(word) do | |
Keyword.get(dictionary, signature(word), []) | |
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
module SystemHook | |
private | |
def system(*args) | |
super.tap do |result| | |
puts "system(#{args.join(', ')}) returned #{result.inspect}" | |
end | |
end | |
end | |
class Object |
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 test | |
"just to see" | |
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
module MigrationHelpers | |
def fk(from_table, from_column, to_table=from_column.to_s.sub(/_id$/, 's')) | |
constraint_name = "fk_#{from_table}_#{from_column}" | |
execute %{alter table #{from_table} | |
add constraint #{constraint_name} | |
foreign key (#{from_column}) | |
references #{to_table}(id)} | |
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
dave[~/Play 7:58:42] gem update rails | |
Updating installed gems | |
Updating coffee-rails | |
Fetching: activesupport-3.2.0.rc2.gem (100%) | |
Fetching: activemodel-3.2.0.rc2.gem (100%) | |
Fetching: rack-1.4.0.gem (100%) | |
Fetching: journey-1.0.0.rc4.gem (100%) | |
Fetching: sprockets-2.1.2.gem (100%) | |
Fetching: actionpack-3.2.0.rc2.gem (100%) | |
ERROR: Error installing coffee-rails: |