Skip to content

Instantly share code, notes, and snippets.

View lilyball's full-sized avatar

Lily Ballard lilyball

  • San Leandro, CA
  • 05:07 (UTC -08:00)
  • Twitter @LilyInTech
View GitHub Profile
lilyball /
Created August 23, 2008 03:35
An implementation of the Sieve of Eratosthenes in OCaml
type primality = Prime | Composite | Unknown
type sieve = primality array
exception Out_of_bounds
let make n =
if n < 2 then invalid_arg "Sieve.make"
let sieve = Array.make n Unknown in
sieve.(0) <- Composite;
sieve.(1) <- Composite;
lilyball / 4button-pico-bp.yaml
Last active March 21, 2023 05:10 — forked from crkochan/4button-pico-bp.yaml
Home Assistant Blueprint
View 4button-pico-bp.yaml
name: Lutron Caseta Four-Button Zone Pico Actions
description: Short and long press automations for the Pico four-button remote.
domain: automation
name: Pico Four-Button Zone Remote
description: Select the Pico four-button zone remote to configure.
lilyball / fnmatch.go
Created January 9, 2010 04:16
fnmatch implementation for Go
View fnmatch.go
// Provide string-matching based on fnmatch.3
package fnmatch
// There are a few issues that I believe to be bugs, but this implementation is
// based as closely as possible on BSD fnmatch. These bugs are present in the
// source of BSD fnmatch, and so are replicated here. The issues are as follows:
// * FNM_PERIOD is no longer observed after the first * in a pattern
// This only applies to matches done with FNM_PATHNAME as well
// * FNM_PERIOD doesn't apply to ranges. According to the documentation,
View CGGetActiveDisplayList.swift
import CoreGraphics
func printDisplays() {
var displayCount: UInt32 = 0;
var result = CGGetActiveDisplayList(0, nil, &displayCount)
if (result != 0) {
println("error: \(result)")
let allocated = Int(displayCount)
View .lldbinit
# ...
command script import ~/path/to/
# ...
lilyball / Day of March widget.js
Created September 18, 2020 22:36
Scriptable script that powers a home screen widget
View Day of March widget.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-green; icon-glyph: calendar-alt;
let widget = createWidget()
if (!config.runsInWidget) {
await widget.presentMedium()
View zalgo.nix
self: super:
zalgo =
# make sure we aren't overwriting a package from nixpkgs
assert !super?zalgo;
self.stdenv.mkDerivation {
name = "zalgo";

Keybase proof

I hereby claim:

  • I am lilyball on github.
  • I am lilyball ( on keybase.
  • I have a public key ASBtGqwn5mVxxk8Mx0dzcbre1Tf9FyO9dJeKBkcWTgWvQwo

To claim this, I am signing this object:

View statemachine.swift
class ViewControllerStandIn {
var stateMachine: StateMachine<State>
init(withSomething: Bool) {
if withSomething {
let delegate = FirstDelegate()
self.stateMachine = StateMachine(withInitialState: .A, callback: delegate.didTransitionFrom(from:to:))
} else {
let delegate = SecondDelegate()
self.stateMachine = StateMachine(withInitialState: .B, callback: delegate.didTransitionFrom(from:to:))
View sorted_over.swift
extension Collection {
func sorted<T: Comparable>(over: (Element) -> T) -> [Element] {
var projections: [(T, Index)] ={ (over(self[$0]), $0) })
projections.sort(by: { $0.0 < $1.0 })
return{ self[$0.1] })