This file contains hidden or 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
%{ "published_at" => { "year" => "2016", "day" => "05", "month" => "01" } } | |
# Convert the above to: | |
# { 2016, 05, 01 } | |
# Any recommendations on a "clean" way to make this transformation? |
This file contains hidden or 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 changeset(model, params \\ :empty) do | |
model | |
|> cast(params, @required_fields, @optional_fields) | |
|> parse_markdown | |
end | |
defp parse_markdown(changeset) do | |
changeset | |
|> put_change(:text_html, get_change(changeset, :text)) | |
end |
This file contains hidden or 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 Polyvox.Api.EpisodeView do | |
use Polyvox.Web, :view | |
@attributes ~w(id name)a | |
def render("show.json", %{ episode: episode }) do | |
episode | |
|> Map.take(@attributes) | |
end | |
end |
This file contains hidden or 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
Podcast | |
|> Podcast.Queries.active | |
|> Repo.preload :episodes | |
|> Repo.all | |
# Response: | |
# ** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for :episodes, the given module does not exist |
This file contains hidden or 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 Polyvox.Api.PodcastController do | |
use Polyvox.Web, :controller | |
alias Polyvox.Repo | |
alias Polyvox.Podcast | |
def index(conn, _params) do | |
podcasts = Repo.all(Podcast) | |
render conn, "index.json", data: podcasts |
This file contains hidden or 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
d0dRdaGEev1UeLSnO0(quyMkYTfz2kzCkQBIOIJtQY3evNNcTtvr7vA3k1(P6NiQ0Wiv(nexdroeIsgSkdNOoiHOtPkCmI05eLAHik1Zuvwmf1YH0dvapvyzuKNJW1P0ujyYi10rnkfQhdvxg8ocvBKq5WKYMvvTDK8rsvnlcHpRk9DevzEikAAqXOffJNqQtsb3sbDAsUhHKvseVwb6VkKR0k0i1GUbDfA8JS5qr(qF(jTboYcbTc9P0kgwmMMXInpx3338xo28(pKeM(0ufBE(thP5Cs6WGfZSUpP9FijmLBqRiKxAgfarZngidGpOF6dAOKvd7MrvVVaAfAGBjyKuJF7gNvi7XpCj(5NF(TqW1w(PyinbuWse(b6zvYYaTbgstafS8tu(PpWIKcq1EbdmKMakyn(H4Ue)8Zp)Cj(5NF(HcSfD7hONvjld0gyinbuWYpYWVXkgstafS8BOFs19qCxcSPl3qBRsASczxHgjn1UcnyJYqdzuGa4gYOabWnmJy34q5Ynyu17lGwHgSrzObULGrsnakyZngajzwJ9Bc5TbULGrsn(TBCwHSh)WL4NF(53cbxB5NIH0eqblr4hONvjld0gyinbuWYpr5N(alskav7fmWqAcOG14hI7s8Zp)8ZL4NF(5hkWw0TFGEwLSmqBGH0eqbl)it)gRyinbuWYVH(jv3dXDjWMUbULGrsJyJYqdcwJTenWZa4d2WktRXqd7gOGn3GvjGUHLagz3kUKDdClbJKgLrrdnyvcOl3afEviBbJYqdgen3G8u0CMkwEojt5ZKMZ)((M)Wo3)Hyi14hzZnihJeSc3pYf1mrJTnjGQEFbuI(uAdfDJbYa4d6Nbgs(nbuWQrgq9MHRyZ5MiLBkBSyWM)Lngsy7)qmZnwiA0vOHLagTbkaTMBWAlyZvOrYUyvfkxUbQgouHgj7IvvOC5gwcyeosYSgxZnSeWiA1)Vc3UyJ1CduKfuHgj7IvvOC5YLBq0Wuw6Yk7SYBq1NsXysx5wa |
This file contains hidden or 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
fizzbuzz = fn | |
0, 0, _ -> "FizzBuzz" | |
0, _, _ -> "Fizz" | |
_, 0, _ -> "Buzz" | |
_, _, c -> c | |
end | |
display_fizzbuzz = fn n -> fizzbuzz.(rem(n, 3), rem(n, 5), n) end | |
IO.inspect for n <- 1..100, do: display_fizzbuzz.(n) |
This file contains hidden or 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
import 'dart:io'; | |
void main() { | |
HttpServer.bind('127.0.0.1', 8080).then((server) { | |
server.listen((HttpRequest request) { | |
request.response.write('Hello, World!'); | |
request.response.close(); | |
}); | |
}); | |
} |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using NUnit.Framework; | |
using Rhino.Mocks; | |
using System.Diagnostics; | |
namespace RhinoMocks | |
{ |
This file contains hidden or 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 'rspec' | |
RSpec.configure do |config| | |
config.filter = { :focus => true } | |
# config.exclusion_filter = { :slow => true } | |
end | |
describe "Tests" do | |
it "should run because it is focused", :focus => true do |