Skip to content

Instantly share code, notes, and snippets.

View stueccles's full-sized avatar

Stuart Eccles stueccles

View GitHub Profile
@stueccles
stueccles / array.verse
Last active April 29, 2024 06:38
A Verse module that adds useful functions to Verse Arrays including Map, Reduce etc.
using { /Verse.org/Random }
Array<public> := module:
# Makes an `array` with only unique elements
(Input:[]t where t:subtype(comparable)).Unique<public>()<transacts>:[]t =
var UniqueArray : []t = array{}
for (Value : Input):
if (UniqueArray.Find[Value] > -1) {}
else:

Keybase proof

I hereby claim:

  • I am stueccles on github.
  • I am stueccles (https://keybase.io/stueccles) on keybase.
  • I have a public key ASDrGv3wjj01-cYrZQQXXN7lOw7zyH0l555nGyR2xThY1Ao

To claim this, I am signing this object:

@stueccles
stueccles / in.ex
Created October 16, 2015 18:29
Checking for a current order
defp check_for_order(conn, _params) do
case get_current_order do
nil ->
conn |> redirect(to: "/") |> halt
order ->
assign(conn, :order, order)
end
end
@stueccles
stueccles / in.ex
Last active October 15, 2015 19:17
Select a single row from an Ecto association
def line_item_query(order, variant_id) do
from l in assoc(order, :line_items),
where: l.variant_id == ^variant_id,
select: l
end
@stueccles
stueccles / in.ex
Created October 15, 2015 18:53
Iterate with Index
for {img, index} <- Enum.with_index(product_images) do
@stueccles
stueccles / run_seeds.ex
Last active October 15, 2015 18:51
Run Database Seeds
mix run priv/repo/seeds.exs