Skip to content

Instantly share code, notes, and snippets.

View smpallen99's full-sized avatar

Steve Pallen smpallen99

View GitHub Profile
@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 / constants.ex
Created April 5, 2014 18:22
Approach for constants shared between modules in Elixir
defmodule Constants do
@moduledoc """
An alternative to use @constant_name value approach to defined reusable
constants in elixir.
This module offers an approach to define these in a
module that can be shared with other modules. They are implemented with
macros so they can be used in guards and matches
## Examples:
@smpallen99
smpallen99 / settings
Created March 8, 2020 20:23
VS Code Settings
.
@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 / upgrade.md
Last active September 9, 2018 21:57
Coherence 0.5.x to 0.6.0 Upgrade Instructions

Coherence 0.5.x to 0.6.0 Upgrade Instructions

Upgrade your generated Controllers

Coherence 0.6.0 introduces a new controller design that splits each controller into 2 files:

  • Coherence.xxxControllerBase contains all the functions previously found in Coherence.xxxController
    • The new functions are wrapped in a using macro, with one mandatory option. The schemas option specifies the name of your projects Schemas module.
    • All functions are overridable
    • All private functions have been made public to support overriding
  • Coherence.xxxController contains only a few lines, as shown by the following example:
@smpallen99
smpallen99 / test.md
Last active February 14, 2018 00:46

Heading

Here is some text just after the heading. It will be follow by one more paragraph that will then be followed by a list. This is to test the formatting which I will compare to github. This will tell me how it looks.

Here is the header line:

  • First List is here
  • Another bullet
  • one more for good measure
@smpallen99
smpallen99 / upgrade.md
Created June 1, 2017 14:42
Upgrade instructions for Talon v0.1.0

The following is required to manually upgrade a project to the stucture required for v0.1.0

@smpallen99
smpallen99 / upgrade.md
Created June 1, 2017 14:42
Upgrade instructions for Talon v0.1.0

The following is required to manually upgrade a project to the stucture required for v0.1.0

@smpallen99
smpallen99 / resource.ex
Last active May 15, 2017 15:39
Example of ExAdminRedux resource file
# ex_admin/lib/ex_admin/resource.ex
# Here is the prototype of the resoruce.ex library in ex_admin.
defmodule ExAdmin.Resource do
defmacro __using__(opts) do
schema = opts[:schema]
unless schema do
raise ":schema is required"
end
@smpallen99
smpallen99 / schema.ex
Created May 15, 2017 05:26
Example ExAdminRedux Ecto Schema Adapter
defmodule ExAdmin.Schema.Adapters.Ecto do
@moduledoc """
Implements the ExAdmin.Scheam.Adapters behaviour.
Add support for Ecto in ExAdin.
"""
@behaviour ExAdmin.Schema.Adapters
@doc """
Retrieve the primay key of a query, schema module, or a schema struct.