Skip to content

Instantly share code, notes, and snippets.

WebSocket connection to 'wss://www.trophus.com/ws/websocket?logger=function%20logger(kind%2C%20msg%2…3A%20%22%20%2B%20msg%2C%20data)%3B%0A%20%20%20%20%20%20%20%20%7D&vsn=1.0.0' failed: Error during WebSocket handshake: Unexpected response code: 403
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
multi_accept on;
}
defmodule Trophus.NotifChannel do
use Trophus.Web, :channel
intercept ["new_msg"]
def join("notifs:" <> user_id, msg, socket) do
IO.puts user_id
{:ok, socket}
end
@stochastic-thread
stochastic-thread / errors.ex
Created August 25, 2015 00:55
Errors running `mix deps.update --all`
➜ trophus git:(master) ✗ mix deps.update --all
* Updating instagram (git://github.com/arthurcolle/exstagram.git)
* Updating compare (git://github.com/trophus/compare.git)
* Updating passport (git://github.com/trophus/passport.git)
* Updating ibrowse (git://github.com/cmullaparthi/ibrowse.git)
* Updating instagrab (git://github.com/arthurcolle/instagrab.git)
* Updating erlastic_search (git://github.com/tsloughter/erlastic_search.git)
Running dependency resolution
Looking up alternatives for conflicting requirements on phoenix_html
Activated version: 2.1.1
[info] Sent 500 in 21164ms
[error] #PID<0.1199.0> running Trophus.Endpoint terminated
Server: 127.0.0.1:4000 (http)
Request: GET /explore
** (exit) an exception was raised:
** (Poison.EncodeError) unable to encode value: {nil, "users"}
(poison) lib/poison/encoder.ex:213: Poison.Encoder.Any.encode/2
(poison) lib/poison/encoder.ex:156: anonymous fn/4 in Poison.Encoder.Map.encode/2
(stdlib) lists.erl:1262: :lists.foldl/3
(poison) lib/poison/encoder.ex:157: Poison.Encoder.Map.encode/2
@stochastic-thread
stochastic-thread / reduce_special.ex
Created July 25, 2015 01:37
Enum.reduce with custom function
m = [%{val: 1}, %{val: 2}, %{val: 10}]
>> [%{val: 1}, %{val: 2}, %{val: 10}]
Enum.reduce(m, 0, fn(%{val: val}, acc) -> acc + val end)
>> 13
@stochastic-thread
stochastic-thread / error.ex
Created July 25, 2015 00:48
OrderItem quantity error
[error] #PID<0.620.0> running Trophus.Endpoint terminated
Server: 127.0.0.1:4000 (http)
Request: POST /add_to_cart
** (exit) an exception was raised:
** (ArgumentError) unknown field `quantity` (note only fields are supported in cast, associations are not)
(ecto) lib/ecto/changeset.ex:248: Ecto.Changeset.type!/2
(ecto) lib/ecto/changeset.ex:231: Ecto.Changeset.process_param/6
(elixir) lib/enum.ex:1100: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(ecto) lib/ecto/changeset.ex:216: Ecto.Changeset.cast/4
(trophus) web/controllers/cart_controller.ex:56: Trophus.CartController.add_to_cart/2
[url: [host: "localhost"], root: "/Users/arthur/Code/elixir/web_apps/trophus",
secret_key_base: "+Zz2pLOLNo",
debug_errors: true,
pubsub: [name: Trophus.PubSub, adapter: Phoenix.PubSub.PG2],
http: [port: 4000], code_reloader: true, cache_static_lookup: false,
watchers: [node: ["node_modules/brunch/bin/brunch", "watch"]], server: true,
live_reload: [patterns: [~r/priv\/static\/.*(js|css|png|jpeg|jpg|gif)$/,
~r/web\/views\/.*(ex)$/, ~r/web\/templates\/.*(eex)$/]]]
@stochastic-thread
stochastic-thread / out.sh
Created July 20, 2015 01:37
iex -S mix while phoenix.server is running
➜ trophus git:(master) ✗ iex -S mix
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Compiled lib/trophus/session.ex
Compiled web/controllers/conversation_controller.ex
Generated trophus app
[error] Running Trophus.Endpoint with Cowboy on http://localhost:4000 failed, port already in use
=INFO REPORT==== 19-Jul-2015::21:37:01 ===
application: logger
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :current_order
def current_order
if !session[:order_id].nil?
Order.find(session[:order_id])
else
Order.new
end