Skip to content

Instantly share code, notes, and snippets.

net / render_in.ex
Last active Jul 7, 2016
Render Phoenix templates inside other templates
View render_in.ex
defmodule YourApp.RenderIn do
@moduledoc """
Renders a block inside another template.
## Usage
# template/page/page.html.eex
<div class="container">
<%= @yield %>
View random_bench.exs
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)
View random.ex
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)>>
net / 1.js
Created Apr 7, 2016
Adding Bootstrap to Phoenix using NPM
View 1.js
// 1. Add Bootstrap as a dependency in package.json
"dependencies": {
"bootstrap": "~3.3.6"
net / gist:2f615ca7da52f49b8069
Created Apr 19, 2015
itg.dark.tmTheme - Ruby Optimized
View gist:2f615ca7da52f49b8069
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
net / gist:b43237844b8715448b11
Last active Aug 29, 2015 API in Ruby
View gist:b43237844b8715448b11
require 'open-uri'
require 'json' # For parsing the response into a hash
# As defined here
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("&")