See https://gist.github.com/net/8cf31d83d44593e54fe6c068ef88855c.
View render_in.ex
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> |
View random_bench.exs
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 |
View random.ex
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 |
View 1.js
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" | |
} | |
} |
View gist:2f615ca7da52f49b8069
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> |
View gist:b43237844b8715448b11
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("&") |