Skip to content

Instantly share code, notes, and snippets.

View zach-klippenstein's full-sized avatar

Zach Klippenstein zach-klippenstein

View GitHub Profile
@riggaroo
riggaroo / BouncyRopes.kt
Last active May 21, 2023 11:58
Jetpack Compose Bouncy Ropes code
/* Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@Composable
fun BouncyRopes() {
val startCoOrdinate by remember {
mutableStateOf(Offset(0f, 0f))
}
var endCoOrdinate by remember {
mutableStateOf(Offset(100f, 0f))
}
@jrodbx
jrodbx / kt2java_diff_hack.sh
Created March 8, 2019 03:58
Hack to enable better Java to Kotlin diffs
#!/usr/bin/env bash
# Find all added *.kt files from last commit and mv to *.java
for f in $(git diff --name-status --diff-filter='A' HEAD~ "*.kt" | cut -f 2);
do mv -- "$f" "${f%.kt}.java";
done
# Commit the kt to java changes
git add .
git commit -m"kt to java"
@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2024 12:32
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,

@eburke
eburke / Main.java
Created March 15, 2016 01:42
Unexpected coin toss probability
import java.util.Random;
/*
If Alice tosses a coin until she sees a head followed by a tail, and Bob tosses a coin until he
sees two heads in a row, then on average, Alice will require four tosses while Bob will require
six tosses (try this at home!), even though head-tail and head-head have an equal chance of
appearing after two coin tosses.
https://www.quantamagazine.org/20160313-mathematicians-discover-prime-conspiracy/
*/
@rbobbins
rbobbins / protocols.md
Last active May 15, 2022 21:08
Notes from "Protocol-Oriented Programming in Swift"

PS: If you liked this talk or like this concept, let's chat about iOS development at Stitch Fix! #shamelessplug

Protocol-Oriented Programming in Swift

Speaker: David Abrahams. (Tech lead for Swift standard library)

  • "Crusty" is an old-school programmer who doesn't trust IDE's, debuggers, programming fads. He's cynical, grumpy.

  • OOP has been around since the 1970's. It's not actually new.

  • Classes are Awesome

    • Encapsulation
    • Access control
@coolaj86
coolaj86 / github-pages-https-lets-encrypt.md
Last active November 16, 2021 22:36
Github Pages: Let's Encrypt!
@staltz
staltz / introrx.md
Last active May 18, 2024 05:17
The introduction to Reactive Programming you've been missing
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#