Skip to content

Instantly share code, notes, and snippets.

View thejohnnybot's full-sized avatar

Johnny Mejias thejohnnybot

  • North Bergen, NJ
View GitHub Profile
@thejohnnybot
thejohnnybot / gist:fd2f9d764da3c27b886e
Last active August 29, 2015 14:04
elixir queryable issue
defmodule Thinker.Controllers.Projects do
use Phoenix.Controller
use Jazz
alias Thinker.Models.Project, as: Project
alias Thinker.Repo, as: Repo
import Ecto.Query
def index(conn, _params) do
query = from p in Project, select: p
projects = Repo.all(query)
(FunctionClauseError) no function clause matching in Jazz.Encoder.Any.to_json/2
Stacktrace
lib/jazz/encoder.ex:115: Jazz.Encoder.Any.to_json({Ecto.Associations.HasMany.Proxy, #Ecto.Associations.HasMany<[name: :issues, target: Thinker.Models.Project, associated: Thinker.Models.Issue, references: :id, foreign_key: :project_id]>}, [])
lib/jazz/encoder.ex:12: Jazz.Encode.it/2
lib/jazz.ex:18: Jazz.encode!/2
lib/jazz/encoder.ex:107: anonymous fn/2 in Jazz.Encoder.Map.encode/3
(elixir) lib/enum.ex:966: anonymous fn/3 in Enum.map/2
(elixir) lib/enum.ex:2235: Enumerable.Map.do_reduce/3
[%Thinker.Models.Project{created_at: %Ecto.DateTime{day: 19, hour: 10,
min: 23, month: 10, sec: 54, year: 2004}, id: 1,
issues: {Ecto.Associations.HasMany.Proxy,
#Ecto.Associations.HasMany<[name: :issues,
target: Thinker.Models.Project, associated: Thinker.Models.Issue,
references: :id, foreign_key: :project_id]>}, name: "projects 1"},
%Thinker.Models.Project{created_at: %Ecto.DateTime{day: 19, hour: 10,
min: 23, month: 10, sec: 52, year: 2004}, id: 2,
issues: {Ecto.Associations.HasMany.Proxy,
#Ecto.Associations.HasMany<[name: :issues,
def anagrams(file \\ "/usr/share/dict/words") do
File.stream!(file)
|> Enum.map(&String.strip/1)
|> Enum.reduce(%{}, fn word, words ->
Map.update(words, Enum.sort(String.graphemes(word)),
[word], &[word | &1])
end)
|> Enum.map(&elem(&1, 1))
|> Enum.slice 1..20
end
<?php
// Error Reporting
//ini_set('display_errors', 'On');
//error_reporting(E_ALL) . "<br />";
$os = strtolower(PHP_OS);
if(strpos($os, "win") === false) ini_set('include_path',ini_get('include_path').':include:../include');
else ini_set('include_path',ini_get('include_path').';include;..\include');
require_once('AastraCommon.php');
@thejohnnybot
thejohnnybot / gist:b36ddf0b9ac7c3a1460a
Last active August 29, 2015 14:07
Elixir test case
defmodule Bond.DataTest do
use ExUnit.Case, async: true
@quotes_fixture_path "test/fixtures/quotes.json"
setup_all do
{:ok, pid} = :cberl.start_link(
:bond_test,
5,
"localhost:8091" |> String.to_char_list,
@thejohnnybot
thejohnnybot / gist:3234018922bbbf05bb88
Created December 5, 2014 03:09
erlang make install
=== Entering application ose
/Applications/Xcode.app/Contents/Developer/usr/bin/make RELEASE_PATH="/Users/johnny/.erlenv/releases/17.0/lib/erlang" release_spec
/usr/bin/install -c -d "/Users/johnny/.erlenv/releases/17.0/lib/erlang/lib/ose-1.0/src"
/usr/bin/install -c -m 644 -p ose.erl "/Users/johnny/.erlenv/releases/17.0/lib/erlang/lib/ose-1.0/src"
/usr/bin/install -c -d "/Users/johnny/.erlenv/releases/17.0/lib/erlang/lib/ose-1.0/include"
/usr/bin/install -c -d "/Users/johnny/.erlenv/releases/17.0/lib/erlang/lib/ose-1.0/ebin"
/usr/bin/install -c -m 644 -p ../ebin/ose.beam ../ebin/ose.app ../ebin/ose.appup "/Users/johnny/.erlenv/releases/17.0/lib/erlang/lib/ose-1.0/ebin"
/Applications/Xcode.app/Contents/Developer/usr/bin/make RELEASE_PATH="/Users/johnny/.erlenv/releases/17.0/lib/erlang" release_spec
make[4]: Nothing to be done for `release_spec'.
test -d "/Users/johnny/.erlenv/releases/17.0/lib/erlang/releases/17" || mkdir -p "/Users/johnny/.erlenv/releases/17.0/lib/erlang/releases/17" ; \
22:18:21.890 [info] Protocol: 'inet_tcp': register/listen error: :econnrefused
1) test start/3 and stop/0 (NodeTest)
test/elixir/node_test.exs:6
match (=) failed
code: {:ok, _} = Node.start(:hello, :shortnames, 15000)
rhs: {:error,
{{:shutdown, {:failed_to_start_child, :net_kernel, {:EXIT, :nodistribution}}},
@thejohnnybot
thejohnnybot / gist:07d10086d850376d719e
Last active August 29, 2015 14:11
CSV Expand Issue
defmodule Helper do
def expand_csv(path) do
path
|> File.stream!
|> Stream.drop(1)
|> Stream.map(&parse_line/1)
|> Stream.flat_map(&expand_csv_row/1)
|> Enum.to_list
end
<form {{action "search" on="submit"}} role="form">
<fieldset>
<legend><i class="fa fa-search">Search Quotes</i></legend>
<div class="row form-group">
<div class="col-xs-6">
<label for="first_name">First Name</label>
{{input class="form-control" name="first_name" value=firstNameField}}
</div>
<div class="col-xs-6">
<label for="last_name">Last Name</label>