Skip to content

Instantly share code, notes, and snippets.


Josh Chernoff joshchernoff

Block or report user

Report or block joshchernoff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
joshchernoff / spec.ex
Last active Jan 12, 2017
An idea of how to write specs.
View spec.ex
defmodule Digitalcakes.PostTest do
use Digitalcakes.ModelCase
alias Digitalcakes.Post
import Digitalcakes.Factory
test "changeset with valid attributes" do
changeset = Post.changeset(%Post{}, params_for(:post))
assert changeset.valid?
test "changeset validates required attributes" do
View A.ex
defmodule A
def init do
collector = spawn(B, :loop, [[], self])
states = [%{"or" => "oregon"}, %{"wa" => "washington"}]
states |> Enum.each(fn (state) ->
send(collector, {:ok, state})
send(collector, :exit)
def loop() do
View gist:5a2b9db03fb529f4bafb89cb529d4107
defmodule Digitalcakes.PostControllerTest do
use Digitalcakes.ConnCase
import Digitalcakes.Factory
alias Digitalcakes.Post
@valid_attrs params_for(:post)
@invalid_attrs %{slug: nil}
test "lists all entries on index", %{conn: conn} do
conn = get conn, post_path(conn, :index)
View console
1) test it inserts with a valid changeset (Pricer.Product.PastPriceRecordTest)
** (ArgumentError) unknown field `product_id`. Only fields, embeds and associations (except :through ones) are supported in changesets
(ecto) lib/ecto/changeset.ex:503: Ecto.Changeset.type!/2
(ecto) lib/ecto/changeset.ex:474: Ecto.Changeset.process_param/8
(elixir) lib/enum.ex:1325: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(ecto) lib/ecto/changeset.ex:450: Ecto.Changeset.do_cast/7
(pricer) lib/pricer/product/past_price_record.ex:15: Pricer.Product.PastPriceRecord.changeset/2
test/pricer/product/past_price_record_test.exs:13: (test)
joshchernoff / config.yml
Created Apr 1, 2017
Circle Ci failure with phoenix and elixir
View config.yml
version: 2
working_directory: ~/digitalcakes
- image: trenpixster/elixir:1.4.0
- image: postgres:9.5.6
View webpack.config.js
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
app: './web/static/js/app.js',
styles: './web/static/css/app.css'
output: {
View Custom phoenix form input helper
defmodule MyAppWeb.InputHelper do
use Phoenix.HTML
def input(form, field, opts \\ []) do
type = Phoenix.HTML.Form.input_type(form, field)
wrapper_classes = Keyword.get_values(opts, :wrapper_class) ++ ["row", "form-group"]
inputs_classes = Keyword.get_values(opts, :input_class) ++ ["form-control"]
if form.errors[field], do: inputs_classes = inputs_classes ++ ["form-control-dange"]
View actions
export const sortColumn = column => {
return dispatch => {
return dispatch({
type: "SORT_COLUMN",
export const sortProjects = column => {
View cli.ex
defmodule Sequencer.CLI do
def main(args \\ []) do
if length(args) > 0 do
# Got something from args
# Got something from STDIN
case, :line) do
:eof ->
You can’t perform that action at this time.