Skip to content

Instantly share code, notes, and snippets.

@coreyhaines
coreyhaines / Flow.elm
Last active December 14, 2020 00:20
General workflow-management
module Flow exposing (Flow(..), map, withDefault, mapDefault, view, update)
import Html
type Flow state
= NotRunning
| Running state
@coreyhaines
coreyhaines / Animation.elm
Last active June 19, 2017 14:48
Animation support library
module Animation exposing (..)
import Task
import Process
import Time exposing (Time, millisecond)
type Animation state
= Setup state
| Animate state
function directory_to_titlebar {
local pwd_length=42 # The maximum length we want (seems to fit nicely
# in a default length Terminal title bar).
# Get the current working directory. We'll format it in $dir.
local dir="$PWD"
# Substitute a leading path that's in $HOME for "~"
if [[ "$HOME" == ${dir:0:${#HOME}} ]] ; then
dir="~${dir:${#HOME}}"
fi
@coreyhaines
coreyhaines / slack_delete.rb
Created August 21, 2016 02:08 — forked from jamescmartinez/slack_delete.rb
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@coreyhaines
coreyhaines / Cleanedup_Item.elm
Created July 16, 2016 18:18
Some elm cleanup
updateItemBasedOnEditItemState : EditItemType -> Item -> Item
updateItemBasedOnEditItemState editItemType item =
let
stopEditing : { item | typeData : ItemTypeData } -> (Maybe.Maybe newEditState -> ItemTypeData) -> { item | typeData : ItemTypeData }
stopEditing item itemTypeDataWithoutEditState =
{ item | typeData = itemTypeDataWithoutEditState Nothing }
updateEditingState : { item | typeData : ItemTypeData } -> (Maybe.Maybe newEditState -> ItemTypeData) -> newEditState -> { item | typeData : ItemTypeData }
updateEditingState item itemTypeDataWithoutEditState editItem =
{ item | typeData = itemTypeDataWithoutEditState (Just editItem) }
@coreyhaines
coreyhaines / outline
Created May 4, 2016 13:45
Fun with Lambdas
# Welcome
## Start with a Lambda
## Get to Hello, world
# What is a lambda
## Ruby Syntax
## Identity
## K
## GetFirst
## GetSecond
@coreyhaines
coreyhaines / abstract
Created April 6, 2016 13:09
Prolog Talk Abstration
Title: I don't know Prolog, and so can you
Abstract: Prolog is a wildly popular declarative logic programming language that all the hot startups and whiz kids are using these days. So, being neither a hot startup nor a whiz kid, I figured I'd learn it. In this talk, I'll share some of the early learnings I've had that can only be considered "mind-bending."
We'll look at a bit of the syntax, the solver model and then dive into some wild and crazy list operations. Finding all the combinatorial variations of a list using the function isMember? Yup! We'll do that.
If you are anything like me, and I know you are, you'll come away from this talk saying "I'm sold! PROLOG FOREVER!"
@coreyhaines
coreyhaines / replacement.rb
Last active August 29, 2015 14:25
Basic templating - better way?
def render_template template, question:
template % {
:"question.text" => CGI::escapeHTML(question.display_text.to_s),
:"question.name" => CGI::escapeHTML(question.name.to_s),
:"question.email" => CGI::escapeHTML(question.email.to_s)
}
end
@coreyhaines
coreyhaines / gist:8545bc5624d50bdae14c
Last active August 29, 2015 14:22
Type-based stack
class TypeStack {
public void push(T obj);
public T pop<T>();
public T peek<T>();
}
var stack = new TypeStack();
stack.push("hello");
var o = new OtherType();
stack.push(o);
Idea based on this tweet exchange:
coreyhaines: Architecture where ever class is its own gem, communicating via drb. #thoughtleadering #thoughtlendering
coreyhaines: better yet, every method is its won gem, classes are built up by requiring gems that monkey-patch. #truth
josh_cheek: @coreyhaines As each method is a gem, it needs its a namespace, so it's defined in a module… Compose classes by including method's modules.
coreyhaines: @josh_cheek I do like the idea of composing via module inclusions, as well. Interesting.
coreyhaines: Seriously, though, the idea of defining classes via including single-method modules appeals to me.
So, here's my thought for the workshop. It is based a bit on some of the value that I saw doing coderetreats.
title: Super Awesome Happy Fun Coding Workshop, Great Job