Skip to content

Instantly share code, notes, and snippets.

View trbngr's full-sized avatar

Chris Martin trbngr

  • Phoenix, AZ, USA
View GitHub Profile
@trbngr
trbngr / .formatter.exs
Last active June 18, 2021 20:12
Phoenix Socket Macros
[
locals_without_parens: [handle_message: 2, handle_message: 3],
import_deps: [:ecto, :phoenix, :cqrs_tools],
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
subdirectories: ["priv/*/migrations"]
]
@trbngr
trbngr / ord.ex
Last active December 2, 2019 02:28
Beging the Ord protocol
defprotocol Ord do
@doc """
iex> Ord.compare("a", "b")
:EQ
iex> Ord.compare("a", "b", type: :alphabetical)
:LT
"""
def compare(a, b, opts \\ [])
def lt(a, b)
def lte(a, b)
@trbngr
trbngr / results
Last active May 24, 2019 03:31
roman numerals benchmarks
Operating System: macOS
CPU Information: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
Number of Available Cores: 8
Available memory: 16 GB
Elixir 1.8.1
Erlang 21.2
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
@trbngr
trbngr / dates.ex
Last active March 23, 2019 01:36
parse dates
defmodule Dates do
@valid_dates [
Date.utc_today() |> Date.to_iso8601(),
NaiveDateTime.utc_now() |> NaiveDateTime.to_iso8601(),
DateTime.utc_now() |> DateTime.to_iso8601()
]
|> Enum.map(&to_string/1)
|> Enum.join(" or ")
@invalid_date_message "Invalid date. Expected formated date. ie #{@valid_dates}"
@trbngr
trbngr / retryable.ex
Last active December 20, 2018 22:18
Elixir Retryable
defmodule Retryable do
require Logger
@enforce_keys [:mfa]
defstruct mfa: nil,
retries: 1,
should_retry: nil,
before_execution: nil
@trbngr
trbngr / KnightsDialer.ex
Last active October 10, 2018 04:36
Knights Dialer in Elixir.
defmodule KnightsDialer do
@nieghbors_map %{
1 => [6, 8],
2 => [7, 9],
3 => [4, 8],
4 => [3, 9, 0],
5 => [],
6 => [1, 7, 0],
7 => [2, 6],
8 => [1, 3],
@trbngr
trbngr / install.sh
Last active September 19, 2018 23:36 — forked from jeherve/install.sh
Installing my favorite apps on a new machine https://jeremy.hu/homebrew-cask-automate-mac-install/
#!/bin/sh
echo Install all AppStore Apps at first!
# If you are looking into a solution to automate AppStore installs,
# check mas https://github.com/argon/mas
# I installed XCode, Forklift.
read -p "Press any key to continue... " -n1 -s
echo '\n'
# Install Homebrew
@trbngr
trbngr / App.js
Last active February 19, 2019 10:20
Render hidden, allow download.
import React from 'react';
import Pdf from './Pdf';
import PdfRenderer from './PdfRenderer';
export default () => (
<PdfRenderer
fileName="settlements.pdf"
buttonClasses="btn btn-secondary view-pdf"
extra={1}
@trbngr
trbngr / Syntax.cs
Last active September 14, 2017 06:42
experiments in graphql-dotnet syntax
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using GraphQL;
using GraphQL.Builders;
using GraphQL.Resolvers;
using GraphQL.Types;
using LanguageExt;
using static LanguageExt.Prelude;
@trbngr
trbngr / build.sbt
Last active January 11, 2017 02:31
name := "eff-study"
version := "1.0"
scalaVersion := "2.12.1"
scalacOptions ++= Seq(
"-Ypartial-unification",
"-language:postfixOps",
"-language:implicitConversions",
"-language:higherKinds"
)