Skip to content

Instantly share code, notes, and snippets.

View hyukhur's full-sized avatar

Hyuk Hur hyukhur

View GitHub Profile
//
// EnumCollection.swift
// Created by Wanbok Choi on 2017. 4. 12..
//
protocol EnumCollection: Hashable {
static var iterator: AnyIterator<Self> { get }
static var allValues: [Self] { get }
}
@andymatuschak
andymatuschak / States-v3.md
Last active April 14, 2025 22:47
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 28, 2025 00:02
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@trevmex
trevmex / git_prompt.sh
Created July 24, 2012 15:06
Add git messaging to your bash prompt
#
# Colors
#
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NORMAL="\[\033[0m\]"
#
# Prompt Setup
@gerald-kim
gerald-kim / Makefile
Created May 25, 2012 10:54
Ad@m 라이브러리에 포함되어있는 Reachability.o 제거하기
libAdamPublisher-without-Reachability.a: libAdamPublisher.a
for arch in armv6 armv7 i386 ; do \
lipo -thin $${arch} libAdamPublisher.a -o $${arch}.a; \
ar -d $${arch}.a Reachability.o; \
done
lipo -create armv6.a armv7.a i386.a -o libAdamPublisher-without-Reachability.a
rm armv6.a armv7.a i386.a
@benelog
benelog / ConnectionMonitor.java
Last active September 3, 2021 19:18
Btrace scripts
import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.BTraceUtils.Aggregations;
import com.sun.btrace.BTraceUtils.Sys;
import com.sun.btrace.aggregation.Aggregation;
import com.sun.btrace.aggregation.AggregationFunction;
import com.sun.btrace.annotations.BTrace;
import com.sun.btrace.annotations.Duration;
import com.sun.btrace.annotations.Kind;
import com.sun.btrace.annotations.Location;
import com.sun.btrace.annotations.OnEvent;