Skip to content
View unroundedFixed.js
function unroundedFixed(number, precision) {
let [left, right] = number.toString().split('.');
[right] = right.match(new RegExp(`[0-9]{${precision}}`));
return [left, right].join('.');
View session_controller.ex
defmodule SogApi.SessionController do
use SogApi.Web, :controller
import Comeonin.Bcrypt
import SogApi.Authenticator
alias SogApi.Account
alias SogApi.AccountSerializer
plug :attempt_to_authenticate, "before delete" when action in [:delete, :show]
View authenticated.ex
defmodule SogApi.Authenticator do
import Plug.Conn
def attempt_to_authenticate(conn, _) do
case find_account(conn) do
{ :ok, account } ->
assign(conn, :account, account)
:error ->
|> send_resp(401, "")
View deserializer.ex
defmodule SogApi.Deserialize do
def init(options) do
def call(%Plug.Conn{params: %{"format" => "json-api"}, method: "POST"}=conn, _opts) do
result = _deserialize(conn)
def call(%Plug.Conn{params: %{"format" => "json-api"}, method: "PUT"}=conn, _opts) do
View serializer.ex
defmodule SogApi.AccountSerializer do
use JaSerializer
serialize "account" do
attributes [
View gist:df6f55af54d59c47b3f6
** (Protocol.UndefinedError) protocol Access not implemented for SogApi.Account, only the nil atom is supported
(elixir) lib/access.ex:145: Access.Atom.undefined/1
lib/ja_serializer/builder/included.ex:11: anonymous fn/1 in
(elixir) lib/enum.ex:662: anonymous fn/3 in Enum.filter/2
(elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:662: Enum.filter/2
lib/ja_serializer/builder/included.ex:11: anonymous fn/2 in
(elixir) lib/enum.ex:793: anonymous fn/3 in Enum.flat_map/2
(elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
View node-server.js
setInterval(function() {
var time =;
arduinos.forEach(function(arduino) {
// each "arduino" is an instance of an Arduino
// class that has a websocket connected to the
// actual corresponding Arduino hardware
arduino.send({currentTime: time});
}, 1000);
View output
➜ ecto git:(bc-rename-column) ✗ MIX_ENV=mysql iex -S mix test integration_test/sql/migration.exs:261
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Including tags: [line: "261"]
Excluding tags: [:test]
Request to pry #PID<0.233.0> at lib/ecto/adapters/mysql/connection.ex:28. Allow? [Yn] y
Interactive Elixir (1.0.5) - press Ctrl+C to exit (type h() ENTER for help)
09:26:48.673 [error] GenServer #PID<0.113.0> terminating
View mysql.ex.result
1) test rename column (Ecto.Integration.MigrationTest)
** (Mariaex.Error) (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @rename_stmt = concat('ALTER TABLE `rename_col_migration` CHANGE COLUMN `to_' at line 2
(ecto) lib/ecto/adapters/sql.ex:222: Ecto.Adapters.SQL.query/5
(ecto) lib/ecto/adapters/mysql.ex:91: Ecto.Adapters.MySQL.execute_ddl/3
integration_test/sql/migration.exs:127: Ecto.Integration.MigrationTest.RenameColumnMigration.up/0
(stdlib) timer.erl:194:
(ecto) lib/ecto/migration/runner.ex:22:
(ecto) lib/ecto/migrator.ex:113: Ecto.Migrator.attempt/6
Something went wrong with that request. Please try again.