Skip to content

Instantly share code, notes, and snippets.

View smpallen99's full-sized avatar

Steve Pallen smpallen99

View GitHub Profile
@smpallen99
smpallen99 / channel_router.ex
Created February 22, 2017 22:21
Channel Router partially complete
defmodule UcxChat.ChannelRouter do
use ChannelRouter
@module __MODULE__
def match(:post, socket, ["typing"], params) do
# module and action are build by the post macro
apply(UcxChat.TypingChannelController, :create, [socket, params])
end
@smpallen99
smpallen99 / Life.ex
Created January 12, 2017 18:25
Tree of Life Implementation in Elixir
# Refer to https://www.hackerrank.com/challenges/the-tree-of-life for the problem description
defmodule Life do
use Bitwise
def run do
rule = read_int
initial_state = IO.gets("") |> String.trim
for _ <- 1..read_int() do
[i, node] = IO.gets("") |> String.trim |> String.split(" ")
@smpallen99
smpallen99 / language
Created January 4, 2017 19:06
BrainF__k interpreter test case
> Increment data pointer so that it points to next location in memory.
< Decrement data pointer so that it points to previous locaion in memory.
+ Increment the byte pointed by data pointer by 1. If it is already at its maximum value, 255, then new value will be 0.
- Decrement the byte pointed by data pointer by 1. If it is at its minimum value, 0, then new value will be 255.
. Output the character represented by the byte at the data pointer.
@smpallen99
smpallen99 / upgrade.md
Last active November 27, 2016 04:35
Coherence 0.3.0 to 0.3.1 Upgrade Instructions

Coherence 0.3.0 to 0.3.1 Upgrade Instructions

Update your configuration

A couple email configuration items have changed.

replace:

config :coherence,

Coherence 0.2.0 to 0.3.0 Upgrade Instructions

Update your Coherence deps

def deps do
  [{:coherence, "~> 0.3.0"},
  ...]
end
@smpallen99
smpallen99 / cloudSettings
Last active March 8, 2020 20:16
ExAmin Dynamic Form using Ajax
{"lastUpload":"2020-03-08T20:15:59.345Z","extensionVersion":"v3.4.3"}
@smpallen99
smpallen99 / console
Created October 17, 2015 16:22
Parsing Elixir with leex and yecc
iex(13)> :leex.file('list_lexer.xrl') ; c("list_lexer.erl")
[:list_lexer]
iex(14)> source = "[one: 1, two: 2, :three, 4]"
"[one: 1, two: 2, :three, 4]"
iex(15)> {:ok, tokens, _} = source |> String.to_char_list |> :list_lexer.string
{:ok,
[{:"[", 1}, {:key, 1, :one}, {:int, 1, 1}, {:",", 1}, {:key, 1, :two},
{:int, 1, 2}, {:",", 1}, {:atom, 1, :three}, {:",", 1}, {:int, 1, 4},
{:"]", 1}], 1}
iex(16)> c("helpers.ex")
@smpallen99
smpallen99 / cfg.conf
Created April 12, 2015 12:43
Conform tuple support
# Provide documentation for cfg.settings.login_defaults here.
cfg.settings.login_defaults = {/orange,initiate@example.com}, {/orange/monitor,admin@example.com}
@smpallen99
smpallen99 / application.html.eex
Last active April 17, 2017 13:12
Phoenix content_for prototype
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Hello Phoenix!</title>
@smpallen99
smpallen99 / ex_form.ex
Last active August 29, 2015 14:15
Elixir form helpers prototype
defmodule ExForm do
@moduledoc """
Prototype for a helpers to generate html forms. Usable with Phoenix.
"""
@doc """
Generates a html form.
## Syntax:
1. pass model name atom and use input_field