Skip to content

Instantly share code, notes, and snippets.

View types.markdown

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

yang-wei /
Last active Jan 28, 2023
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !


myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
mgold /
Last active Mar 24, 2020
Using Mailboxes in Elm: a tutorial blog post

Using Mailboxes in Elm

Max Goldstein | July 30, 2015 | Elm 0.15.1

In Elm, signals always have a data source associated with them. Window.dimensions is exactly what you think it is, and you can't send your own events on it. You can derive your own signals from these primitives using map, filter, and merge, but the timing of events is beyond your control.

This becomes a problem when you try to add UI elements. We want to be able to add checkboxes and dropdown menus, and to receive the current state of these elements as a signal. So how do we do that?

The Bad Old Days

tiegz / mailgun_batch_smtp.rb
Last active Jul 18, 2018
Getting Mailgun SMTP Batch emails to work in ActionMailer.
View mailgun_batch_smtp.rb
class FoobarMailer < BaseMailer
# The method you'll actually call to generate the batched email
def batched_foobar
# Recipient Variables
recipients = {"" => {"name" => "You Youington"}}
mail(to: "") do |format|
# Mailgun requires you to base64 your Recipient Variables JSON
format.custom('application/json', content_transfer_encoding: "base64") do
render text: Base64.encode64(recipients.to_json)
schickling / Rakefile
Last active Jan 16, 2023
Activerecord without Rails
View Rakefile
require "active_record"
namespace :db do
db_config = YAML::load('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
marc0der / gist:6015948
Last active May 24, 2022
Higher order function in bash!
View gist:6015948
function printit {
echo "This is from an embedded function: $1"
function printthat {
echo "This is the first line."
$1 $2
echo "This is the third line."
jasonrudolph /
Created Feb 12, 2012
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
pfleidi / fiberchat.rb
Created Feb 19, 2011
A naive socket chat using select() and ruby fibers
View fiberchat.rb
require 'rubygems'
require 'socket'
include Socket::Constants
class ChatServer
def initialize
@reading =
@writing =
@clients =