Skip to content

Instantly share code, notes, and snippets.

View edwinallenz's full-sized avatar
🏠
Working from home

Edwin Allen edwinallenz

🏠
Working from home
View GitHub Profile
#/slack_jira_comments/web/router.ex
defmodule SlackJiraComments.Router do
use SlackJiraComments.Web, :router
pipeline :api do
plug :accepts, ["json"]
end
scope "/", SlackJiraComments do
@edwinallenz
edwinallenz / mix.exs
Last active May 25, 2017 04:28
Snippets for Jira Issue comments & Slack integration with Phoenix
defp deps do
[{:phoenix, "~> 1.2.1"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.0"},
{:rethinkdb, "~> 0.4.0"},
{:rethinkdb_ecto, "~> 0.7"},
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"}]
end
defmodule HelloPhoenixApi.HelloViewTest do
use HelloPhoenixApi.ConnCase, async: true
use ExUnit.Case
test "GET /" do
conn = get build_conn(), "/"
assert conn.state == :sent
assert conn.status == 200
@edwinallenz
edwinallenz / hello_view.ex
Created March 25, 2017 02:18
Phoenix Json API view
defmodule HelloPhoenixApi.HelloView do
use HelloPhoenixApi.Web, :view
def render("index.json", %{}) do
%{hello: "world"}
end
end
@edwinallenz
edwinallenz / hello_controller.ex
Created March 25, 2017 01:05
Hello controller to handle route
defmodule HelloPhoenixApi.HelloController do
use HelloPhoenixApi.Web, :controller
def index(conn, _params) do
render conn, "index.json"
end
end
@edwinallenz
edwinallenz / router.ex
Created March 24, 2017 23:49
Router phoenix mix scaffold p02
defmodule HelloPhoenixApi.Router do
use HelloPhoenixApi.Web, :router
pipeline :api do
plug :accepts, ["json"]
end
scope "/", HelloPhoenixApi do
pipe_through :api # Use the default browser stack
@edwinallenz
edwinallenz / router.ex
Last active March 24, 2017 23:47
Router phoenix mix scaffold p01
defmodule HelloPhoenixApi.Router do
use HelloPhoenixApi.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
@edwinallenz
edwinallenz / 0_reuse_code.js
Created October 31, 2016 18:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@edwinallenz
edwinallenz / machina-test.js
Last active June 21, 2016 22:23
Machina test
const Machina = require ('machina')
const vSignal = new Machina.Fsm({
initialize: (options) => {
},
namespace: 'vehicle-signal',
initialState: "uninitialized",
states:{
uninitialized:{
"*": _ => {
input {
http {
codec => json
}
}
output {
stdout { codec => rubydebug}
irc {
channels => ["#layer"]
host => "irc.server"