Skip to content

Instantly share code, notes, and snippets.

window.stoppingPropagation = (callback) -> (e) ->
e.stopPropagation()
callback(e)
angular.module('myApp',[]).directive 'ngTap', ->
(scope, element, attrs) ->
tapping = false
element.bind 'touchstart', stoppingPropagation (e) -> tapping = true
element.bind 'touchmove', stoppingPropagation (e) -> tapping = false
element.bind 'touchend', stoppingPropagation (e) -> scope.$apply(attrs['ngTap']) if tapping
@geelen
geelen / flake-test.ts
Last active November 6, 2025 09:06
Flake Tester
#!/usr/bin/env bun
/**
* Flake Test Runner
*
* A utility for repeatedly running potentially flaky tests to measure their reliability.
* Each run is logged to a separate file, and exit codes are tracked to calculate statistics.
*
* Requirements:
* - Bun runtime (https://bun.sh) - a fast JavaScript runtime and toolkit

Reverting multiple commits

Realised you can use git-reset in a funky way if you're trying to repair a repo that's got into a dodgy state. If you're working locally, you can use git reset --hard or git rebase -i or whatever to rewrite your history (if you're into that sort of thing) but when the commits have already been pushed things are slightly more complicated.

TL;DR

git reset --hard last_good_commit
git reset --soft ORIG_HEAD
git commit -m 'threw away changes back to last_good_commit'

git push

@geelen
geelen / we_are_all_doomed.rb
Created October 14, 2012 03:40
The 25 most-watched videos on Youtube
[{:title=>"Justin Bieber - Baby ft. Ludacris",
:url=>
"http://www.youtube.com/watch?v=kffacxfA7G4&feature=youtube_gdata_player",
:count=>771124453},
{:title=>"Jennifer Lopez - On The Floor ft. Pitbull",
:url=>
"http://www.youtube.com/watch?v=t4H_Zoh7G5A&feature=youtube_gdata_player",
:count=>583464097},
{:title=>"Eminem - Love The Way You Lie ft. Rihanna",
:url=>
@geelen
geelen / maybe-error.md
Last active January 4, 2024 22:51
"Maybe Error" pattern in Typescript

"Maybe Error" pattern in Typescript

TL;DR? 👉 Implementation.

Inspiration

So one of the things I've liked about working with Go is that you use multiple return values a lot, with early exits that work as a kind of guard:

func GetUserFromAuth(name string, auth Auth) (error, User) {
@geelen
geelen / curl + jq.md
Created January 26, 2023 21:23
ZSH aliases

Idiot-Proof Git Aliases

@geelen
geelen / idea.md
Last active June 11, 2020 19:51
Cracking the Cryptic webapp helper

Cracking the Cryptic sudoku webapp helper

This just detects if you've made a clear error as you're solving something (only looks at the basic sudoku rules, nothing fancy):

image

To install, just open your developer console (⌘⇧I or Cmd Shift I, then select console) and paste in the source code below:

@geelen
geelen / a.md
Last active May 29, 2020 17:34
(all night) Long HTTP Request demo

Example of FAB streaming.

  1. Open https://www.youtube.com/watch?v=nqAvFx3NxUM
  2. Paste the following in the terminal:
curl "https://despacito.glen.workers.dev/?https://gist.githubusercontent.com/geelen/779758741e57f717a93e7bff7f2a6c5f/raw/ac8eb260f7fd2130ff5b648b91924ce1262262b0/lyrics.vtt"
  1. About 11 seconds into the video, hit enter.
@geelen
geelen / traits.ts
Created April 7, 2020 10:03
ARGH TYPESCRIPT WHY WONT YOU OBEY ME
import { css } from 'styled-components'
type RulesDefn = {
[k: string]: string
}
type TrainBuilder<T extends RulesDefn> = {
[k in keyof T]: TrainBuilder<T>
} & {
toString: () => string[]