See https://gist.github.com/net/8cf31d83d44593e54fe6c068ef88855c.
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 YourApp.RenderIn do | |
@moduledoc """ | |
Renders a block inside another template. | |
## Usage | |
# template/page/page.html.eex | |
<div class="container"> | |
<%= @yield %> | |
</div> |
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 Random do | |
use Benchfella | |
@list ~w(a b c d e f g h i j k l m n o p) | |
@tuple List.to_tuple(@list) | |
bench "tuple" do | |
_ = elem(@tuple, :random.uniform(16) - 1) | |
:ok | |
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
defmodule Random do | |
@allowed_characters 'abcdefghijklmnopqrstuvwxyz1234567890' | |
def generate(length), do: generate(length, "") | |
def generate(0, acc), do: acc | |
def generate(length, acc), do: generate(length - 1, acc <> random_char) | |
def random_char, do: <<Enum.random(@allowed_characters)>> | |
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
// 1. Add Bootstrap as a dependency in package.json | |
{ | |
... | |
"dependencies": { | |
... | |
"bootstrap": "~3.3.6" | |
} | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>author</key> | |
<string>@itg</string> | |
<key>colorSpaceName</key> | |
<string>sRGB</string> | |
<key>name</key> | |
<string>itg.dark</string> |
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
require 'open-uri' | |
require 'json' # For parsing the response into a hash | |
# As defined here http://www.astro-phys.com/api | |
call = 'coefficients' # note: '/api/de406/' is not needed | |
parameters = ['bodies=sun'] # e.g. ['bodies=venus', 'type=m'] | |
# Converts parameters to query string | |
unless parameters.empty? | |
parameters = parameters.join("&") |