Skip to content

Instantly share code, notes, and snippets.

View jessesquires's full-sized avatar
🏴
free labor

Jesse Squires jessesquires

🏴
free labor
View GitHub Profile
@inamiy
inamiy / SwiftElmFrameworkList.md
Last active March 11, 2024 10:20
React & Elm inspired frameworks in Swift
#!/bin/bash
for f in `ls *.gyb`
do
echo "Processing $f"
name=${f%.gyb}
../../../utils/gyb -D CMAKE_SIZEOF_VOID_P=8 -o $name $f --line-directive ""
done
@andymatuschak
andymatuschak / States-v3.md
Last active April 12, 2024 16:06
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,

@danieleggert
danieleggert / GPG and git on macOS.md
Last active April 22, 2024 07:46
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@steipete
steipete / PresentActionSheetWorkaround.mm
Last active January 27, 2020 04:32
UIKit has two places where it tries to present an action sheet on the rootViewController when it should present things on the topmost presentedViewController. This is our attempt of the least horrible workaround to fix this issue. (http://www.openradar.me/26295020).
#warning This still misses safeguards and has private API references in it. Use only when you really know what you're doing!
// pspdf_swizzleSelectorWithBlock not provided. Use your swizzling helper of choice
// (e.g. http://petersteinberger.com/blog/2014/a-story-about-swizzling-the-right-way-and-touch-forwarding/)
// Fixes rdar://26295020
static void PSPDFInstallWorkaroundForSheetPresentationIssue26295020(void) {
__block auto removeWorkaround = ^{};
const auto installWorkaround = ^{
const SEL presentSEL = @selector(presentViewController:animated:completion:);
@chockenberry
chockenberry / finder_icons.sh
Last active February 10, 2024 19:05
A simple shell script to turn the Finders desktop icons on and off
#!/bin/sh
defaults read com.apple.finder CreateDesktop > /dev/null 2>&1
enabled=$?
if [ "$1" = "off" ]; then
if [ $enabled -eq 1 ]; then
defaults write com.apple.finder CreateDesktop false
osascript -e 'tell application "Finder" to quit'
open -a Finder
import Cocoa
import MASShortcut
func pow() {
let rect = NSScreen.mainScreen()?.frame
let window = NSWindow(contentRect: rect!, styleMask: NSBorderlessWindowMask, backing: .Buffered, `defer`: false)
window.backgroundColor = NSColor.clearColor()
window.opaque = false
window.alphaValue = 1
window.makeKeyAndOrderFront(NSApplication.sharedApplication())
// We're going to try to build a collectionview layout engine that can serve up cells and supplementary views
// in a generic way. I haven't built this all the way to the collection view, and I don't konw what the real
// brief is, so there may be lots of gotchas here that don't work as desired, but it scopes out several ways
// to get a handle on the problem and how I'd at least probably start.
// Ultimately, this requires converting (Model, IndexPath) -> Cell and (Model, IndexPath) -> SupView. I'm
// assuming that's the only feature of these factories.
@orta
orta / _SQL.sql
Last active November 8, 2016 12:12
Top 300 Pods by Application Integrations
SELECT pods.name, stats_metrics.download_total, stats_metrics.download_week, stats_metrics.app_total, stats_metrics.app_week FROM stats_metrics JOIN pods ON stats_metrics.pod_id = pods.id ORDER BY app_total DESC LIMIT 300;
@plumhead
plumhead / StringSize.swift
Created September 15, 2015 13:34
String extension to find the layout size of a String with specified attributes.
extension String {
func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect {
let storage = NSTextStorage(string: self)
let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height))
let layout = NSLayoutManager()
layout.addTextContainer(container)
storage.addLayoutManager(layout)
storage.addAttributes(attrs, range: NSMakeRange(0, storage.length))
container.lineFragmentPadding = 0.0
let _ = layout.glyphRangeForTextContainer(container)