export GIT_EDITOR=vim
mkdir foobar
cd foobar
git init
touch .gitignore
echo "*.rb" >> .gitignore
git add .gitignore
vim .git/index
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
describe(List) do | |
describe("#tasks") do | |
it("tells which tasks are in it") do | |
test_list = List.create({:name => "list"}) | |
test_task1 = Task.create({:description => "task1", :list_id => test_list.id}) | |
test_task2 = Task.create({:description => "task2", :list_id => test_list.id}) | |
expect(test_list.tasks()).to(eq([test_task1, test_task2])) | |
end | |
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
module Pangram do | |
def self.is?(string) | |
string | |
.downcase | |
.split("") | |
.select { |character| in_alphabet? character } | |
.uniq | |
.sort == alphabet | |
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
exports.config = { | |
// See http://brunch.io/#documentation for docs. | |
files: { | |
javascripts: { | |
joinTo: "js/app.js" | |
// To use a separate vendor.js bundle, specify two files path | |
// http://brunch.io/docs/config#-files- | |
// joinTo: { | |
// "js/app.js": /^(web\/static\/js)|(node_modules)/, |
So what is GenStage? From the official documentation, it is a "specification and computational flow for Elixir", but what does that mean to us?
There is a lot to something that can be described as that vague, and here we'll take a dive in and build something on top of it to understand its goals.
We could go into the technical and theoretical implications of this, but instead lets try a pragmatic approach to really just get it to work.
First, Let's imagine we have a server that constantly emits numbers. It starts at the state of the number we give it, then counts up in one from there onward. This is what we would call our producer.
Step | Ingredients | What To Do |
---|---|---|
1 | Red Sauce, Onion, Lemon, Basil, Parsley (optional), Garlic Clove, 1/4 Cup Red Wine (optional), Olive Oil, Pepper, Saucepan, Grater, Knife, Some Small Bowls (atleast 2) | Get them together |
2 | Basil, Onion, Lemon, Garlic Clove, Parsley, Knife | Keeping all of them separate, cut the fudge out of the basil til its in chunks you wouldnt mind biting in the suace. Cut them lemon in half. Dice the onion and take as much as you want and set aside. Dice the garlic and take as much as you want and set aside. Chop the parsley finely. |
3 | Saucepan, Olive Oil | Set saucepan to LOW heat, around a 2/10, coat bottom in just a wee bit of olive oil. Let it warm up |
4 | (now chopped) Garlic, (now chopped) Onion, Small Bowl | Once the oil has been sitting a moment, mix together the garlic and onion in a small bowl. Toss them in |
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 FibGenerator do | |
def generate(n) do | |
[zero_index | fibs] = Stream.unfold({0,1}, fn {f1,f2} -> {f1, {f2, f1+f2}} end) | |
|> Enum.take(n) | |
fibs |> List.last | |
end | |
end | |
FibGenerator.generate(250_000) | |
#=> 224693160117288818697854459752207415028542386732410022115057943314342971956353069592280783037229751661300118440162237165757529052197098735750205498373429350007507567116095815705696776672018274988779509622396919660402156686229063708848644322836537994114498662373993440415325984214084957912948825947517820662620603457739506071247463183138258945202422649381326907950942110909977389871263618167010828369863953925462531156442653712410972946762193224778722994582532893450813307599622733884056410122267907808736730086882854950627231358456282518687726696354528859053216876450240151568113496983289916040792824392122100048460447472546550175841759656802309492837856571902161684116688001699177997312814574603886245788507657006915335609421238209022498885192029202308475505307308383988966786 |
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
[alias] | |
l = "!source ~/.githelpers && sexy_git_log" | |
# if alias already exists just add the l line, otherwise add whole section |
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 MyApp.Periodically do | |
use GenServer | |
def start_link do | |
GenServer.start_link(__MODULE__, %{}) | |
end | |
def init(state) do | |
schedule_work() # Schedule work to be performed at some point | |
{:ok, state} |