Skip to content

Instantly share code, notes, and snippets.

View Snippet2.ex
defmodule Snippet do
def snippets do
%{
snippets: [
[
%{
channel: 1,
id: "t-21",
phrase: " yeah it takes a while to cash that in and get the money back and also that ",
View Snippet.ex
defmodule Snippet do
def snippets do
%{
snippets: [
[
%{
channel: 1,
id: "t-21",
phrase: " yeah it takes a while to cash that in and get the money back and also that ",
@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 Mar 7, 2019
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 / short_formats.ex
Last active Sep 2, 2016
Pushing the limits on generating functions at compile time
View short_formats.ex
defmodule Cldr.Number.Generate.ShortFormats do
@moduledoc """
Generates a set of functions to process the various
:short and :long formats for numbers.
"""
alias Cldr.Number.{System, Format}
defmacro __using__(_options \\ []) do
def_to_string() ++ def_do_to_string()
@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
View git.rake
# Rake tasks for managing git plugins with submodules.
#
# These tasks aim to make life simpler by automating all the boring work.
# What you get:
# - complete git integration (all you need to know is install, uninstall and update)
# - complete github integration (only use author name + plugin name)
# - rails plugin hooks (install.rb/uninstall.rb) are taken care of
#
# Available commands:
#
View gist:125680
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
<title>116612 MS Email_FA</title>
</head>
<body>
<table cellspacing="0" border="0" cellpadding="0" align="center" width="600">
View gist:125679
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>116612 MS Email_FA</title>
</head>
<body >
<table width="600" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
You can’t perform that action at this time.