Skip to content

Instantly share code, notes, and snippets.

@demofly
demofly / postgresql-drop-unused-indexes.sh
Created September 27, 2016 11:50
postgresql-drop-unused-indexes.sh
#!/bin/bash
# Written by demofly for Pg 9.4
#
# WARNING: if you ran pg_stat_reset() last month, don't use this script !!!
#
# Get unused indexes and kill it with fire!
DB=postgres
@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,

@emotality
emotality / duplicate_line_xcode.md
Last active April 6, 2024 04:23
Xcode - Duplicate Line key binding

NOTE (2022-07-09): Xcode finally added this functionality in Xcode 14, please see release notes here:

New Features in Xcode 14 Beta 3
When editing code, the Edit > Duplicate menu item and its corresponding keyboard shortcut now duplicate the selected text — or the line that currently contains the insertion point, if no text is selected. (8614499) (FB5618491)


Xcode line duplicate

Bind keys to duplicate lines in Xcode

@romainbriche
romainbriche / AZModel.h
Created July 19, 2012 12:35
Thread-safe NSManagedObjectContext factory.
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface AZModel : NSObject
+ (AZModel *)sharedModel;
- (__strong NSManagedObjectContext *)managedObjectContextForCurrentThread;
- (__autoreleasing NSManagedObjectContext *)newManagedObjectContextForCurrentThread;
@end
@kanemu
kanemu / IndInteractiveConsole.jsx
Created January 19, 2011 12:33
[indesign]InDesign Interactive Console
/*
* InDesign Interactive Console
* @nbqx made the original of this script.
* http://d.hatena.ne.jp/nbqx69/20100617#p1
*/
#target Indesign
#targetengine nbqx
//ユーティリティ