Skip to content

Instantly share code, notes, and snippets.

View boxxxie's full-sized avatar
👙
disrupting absurdism

Paul Iannazzo boxxxie

👙
disrupting absurdism
View GitHub Profile
@boxxxie
boxxxie / match.clj
Created February 28, 2020 18:54
clojure.core.match+ (adding elixir style guards)
(ns loco.match
(:require [meander.epsilon :as m :refer [match]]
[clojure.walk :as walk]))
;;TODO: add this syntax to defun, and improve arglists
(defn guards-to-map
"transforms a single matching clause (with new :guard syntax) into supported syntax
e.g.: [sym _] :guard [sym [pred1 pred2]] return"
([matcher return] (list matcher return))
defmodule Ecto.Schema.Includes do
defmacro include(module) do
quote do
Ecto.Schema.__include__(unquote(module), __MODULE__)
end
end
# Copy the field and association definitions from a module
def __include__(from_module, to_module) do
__include__(:fields, from_module, to_module)
# first_year_maker = fn(path) ->
# fn {current_year, acc} = tuple ->
# acc_con = Map.get(acc, path)
# con = get_in(current_year, path)
# year = current_year.year_index
# case {con, acc_con} do
# {0.0, nil} -> tuple
# {nil, nil} -> tuple
# {nil, _} -> tuple
.agignore
.projectile
[user]
name = Paul Iannazzo
email = somethingitalian@gmail.com
[core]
editor = emacsclient -t
logAllRefUpdates = true
excludesfile = ~/dot_files/.gitignore
[color]
ui = auto
[alias]
mouse_autohide = true
font = monospace 16
## from http://terminal.sexy/
[colors]
# special
foreground = #c5c8c6
foreground_bold = #c5c8c6
cursor = #c5c8c6
# -------------------- transpose --------------------
def transpose(m) do
attach_row(m, [])
end
@doc """
Given a matrix and a result, make the first row into a column,
attach it to the result, and then recursively attach the
remaining rows to that new result.
for f in (find . -type f)
sed -i 's/bad/good/g' $f
end
@doc """
This preforms an index lookup for data structures (tuple/list/Map)
"""
def nth(index) do
fn
tuple when is_tuple(tuple) ->
tuple |> elem(index)
enum ->
enum |> Enum.at(index)
end
@boxxxie
boxxxie / mismatch.ex
Created October 9, 2016 18:06
in the below code, the is_map guard causes this code to take only that path, even when given a MapSet
def empty(%MapSet{}), do: MapSet.new()
def empty(obj) when is_map(obj), do: %{}