Skip to content

Instantly share code, notes, and snippets.

@kofigumbs
kofigumbs / example_usage.rb
Last active November 25, 2016 23:10
Ruby Results
args = # something
Result.try { f(args) }
.and_then { |f_output| g(f_output) }
.finally(
success: proc { |g_output| rended :view },
failure: proc { |error| flash[:error] = error.to_s }
)
@kofigumbs
kofigumbs / test.core
Created March 29, 2017 15:09
How Core Erlang handles nested function application
module 'test' ['f'/0,
'module_info'/0,
'module_info'/1,
'three'/0]
attributes []
'f'/0 =
%% Line 5
fun () ->
%% Line 6
( fun (_cor2) ->
@kofigumbs
kofigumbs / Functio.java
Last active June 15, 2017 04:37
Currying in Java 7
public final class Functio {
abstract static class N1<T, U> {
abstract U apply(T t);
}
abstract static class N2<T, U, V> extends N1<T, N1<U,V>> {
abstract V apply(T t, U u);
@Override
N1<U, V> apply(final T t) {
@kofigumbs
kofigumbs / tea.js
Last active September 2, 2017 20:05
Simple illustration of The Elm Architecture
// This is the thing you give to Elm, your purely functional core,
// which exposes init, view, and update.
const app = require('./business-logic')
// This represents the implementations for all the side effects
// that your program knows how to requests.
// There is only one public function, perform(cmd: Cmd<Msg>) -> Promise<Msg>.
@kofigumbs
kofigumbs / install-sysconfcpus-elm.sh
Last active November 10, 2017 17:32
Use sysconfcpus to simulate CPU count on Travis, for use with Elm
#!/usr/bin/env bash
# https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142
#
# Put these lines in your .travis.yml
#
# install:
# - source <(curl -sSL https://gist.githubusercontent.com/hkgumbs/a434d214628147955f73ff7a7ce4c22c/raw)
# - npm install -g elm elm-test elm-format # etc
#
@kofigumbs
kofigumbs / index.js
Created March 29, 2018 23:19
A tiny express server for compiling Elm
// JSON API
const app = require("express")();
const bodyParser = require("body-parser");
app.use(bodyParser.json())
// COMPILE
@kofigumbs
kofigumbs / elm_converter.rb
Last active March 30, 2019 19:58
Compile Elm files and include the JavaScript output in a Jekyll site
# Initially based on https://github.com/sonnym/jekyll_elm
#
# USAGE:
# Copy/paste this file into the `_plugins` directory of your Jekyll project.
# For every .elm file in your project, it will generate a .js file in your site
# using the same name and relative path.
#
# As-is, the converter expects the following directory structure:
#
# your-jekyll-project/
module Idris exposing (..)
type Num x
= Z
| S (Num x)
type Vect ln a
= Nil
@kofigumbs
kofigumbs / Gemfile
Last active April 14, 2020 22:31
Bulk unfollow inactive users
source 'https://rubygems.org'
gem 'twitter'
elm-stuff