Skip to content

Instantly share code, notes, and snippets.

Kip Cole kipcole9

Block or report user

Report or block kipcole9

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kipcole9
kipcole9 / decode.ex
Created Jan 2, 2020
Decode a float in Elixir
View decode.ex
defmodule Decode do
@moduledoc """
Extracted from https://github.com/ewildgoose/elixir-float_pp
"""
use Bitwise
@float_bias 1022
############################################################################
@kipcole9
kipcole9 / function_clause.ex
Created Oct 23, 2019
Debug Elixir Function Clause errors
View function_clause.ex
defmodule FunctionClause do
@moduledoc """
Format function clauses using Exception.blame/3
"""
@doc """
Given a `module`, `function`, and `args` see
if that function clause would match or not match.
This is useful for helping diagnose function
@kipcole9
kipcole9 / tree walk.ex
Created Feb 16, 2019
Depth-wise tree walk and execute a function
View tree walk.ex
defmodule Treewalk do
@type tree :: {:node, integer(), tree(), tree()} | nil
def depth({:node, value, nil, nil}, _fun) do
value
end
def depth({:node, value, nil, right}, fun) do
fun.(value, depth(right, fun), nil)
end
@kipcole9
kipcole9 / case_insensitive_string
Last active Nov 25, 2018
Case incentive String comparison for ASCII strings
View case_insensitive_string
defmodule InsensitiveString do
@moduledoc """
Case insensitive string functions for
ASCII string
"""
@doc """
Compare two ascii strings in a case insensitive
manner
@kipcole9
kipcole9 / Map.Helpers
Last active Jan 3, 2020
Helpers for Elixir Maps: underscore, atomise and stringify map keys
View Map.Helpers
defmodule Map.Helpers do
@moduledoc """
Functions to transform maps
"""
@doc """
Convert map string camelCase keys to underscore_keys
"""
def underscore_keys(nil), do: nil
@kipcole9
kipcole9 / 0. nginx_setup.sh
Created Jul 13, 2012 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn (production-ready setup)
View 0. nginx_setup.sh
# Nginx optimal congifuration guide.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.2.tar.gz
$ tar xzvf ./nginx-1.2.2.tar.gz && rm -f ./nginx-1.2.2.tar.gz
$ wget http://zlib.net/zlib127.zip
You can’t perform that action at this time.