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
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script> | |
$(function () { | |
$("#myb").click(function () { | |
$.ajax({ | |
url: "/showme", | |
type: "POST", | |
data: {nome: "Jose", sobrenome: "Valim"}, |
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
<% @widgets.each do |widget| %> | |
<p><%= widget.name %></p> | |
<% 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
# Install this recipe with: | |
# brew install https://raw.github.com/gist/1968046/0302279edc972e9d147110bd69284d0e2becda41/elixir.rb | |
require 'formula' | |
class ErlangInstalled < Requirement | |
def message; <<-EOS.undent | |
Erlang is required to install. | |
You can install this with: |
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 Chat.Client do | |
# In all of the following functions 'server' stands for the server's pid | |
def join(server) do | |
send server, :join | |
end | |
def say(server, message) do | |
send server, { :say, message } | |
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
Expected: | |
[ | |
[{"a","b"},{"c","d"}], | |
[{"a1","b1"},{"c1","d1"}], | |
[{"a2","b2"},{"c2","d2"}] | |
] | |
Actual: |
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
def zip(a, b) do | |
list = to_list(a) | |
throw do | |
{ zipped, rest } = Reducers.reduce(b, { [], list }, fn | |
entry, { acc, [h|t] } -> { [{entry, h}|acc], t } | |
entry, { acc, [] } -> throw { :enum_zip, acc } | |
end) | |
:lists.foldl(fn(x, acc) -> |
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
def next_state do | |
(board, x, y) -> | |
cell = cell_at(board, x, y) | |
live_count = live_neighbors(board, x, y) | |
next_state(cell, live_count) | |
(_, x, y) when (x < 0 or y < 0) -> | |
"." | |
end | |
def next_state do |
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 ExCoder do | |
vars = [ { "	", " " }, | |
{ "!", "!" }, | |
{ "" "", "\"" }, | |
{ "#", "#" }, | |
{ "$", "$" }, | |
{ "%", "%" }, | |
{ "& &", "&" }, | |
{ "'", "'" }, | |
{ "(", "(" }, |
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 Dict.Behaviour do | |
# It is assumed that the client module implements following functions: | |
# | |
# size/1, fetch/2, put/3, reduce/3, update/4, delete/2 | |
# | |
defmacro __using__(_) do | |
quote do | |
# Following are exact copies of HashDict: | |
def get(dict, key, default // nil) do |
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
% from my unit tests | |
foo = 10 | |
assert 10 == my_macro(:foo) | |
assert 10 == my_macro("foo") | |
% macro | |
defmacro my_macro(some_var) when is_atom(some_var) do |