Models | Examples |
---|---|
Display ads | Yahoo! |
Search ads |
// Target API: | |
// | |
// var s = require('net').createStream(25, 'smtp.example.com'); | |
// s.on('connect', function() { | |
// require('starttls')(s, options, function() { | |
// if (!s.authorized) { | |
// s.destroy(); | |
// return; | |
// } | |
// |
### | |
Author: Jason Giedymin <jasong _a_t_ apache -dot- org> | |
http://www.jasongiedymin.com | |
https://github.com/JasonGiedymin | |
Appearing in the Quake III Arena source code[1], this strange algorithm uses | |
integer operations along with a 'magic number' to calculate floating point | |
approximation values of inverse square roots[5]. |
// To compile and test this from the command line: | |
// | |
// $> clang FunctionPointerFromMethod.m -ObjC -framework Foundation -fobjc-arc | |
// $> ./a.out | |
#import <Foundation/Foundation.h> | |
@interface MyClass : NSObject | |
- (void)someMethodThatTakesOneStringArgument:(NSString *)string; | |
@end |
var editor = new CodeMirror({ /* ... */ }); | |
fake(editor, "("); // if you have closebrackets.js addon switched on, this will actually generate "()" | |
fake(editor, "enter"); // all the crazy indenting logic will be used | |
fake(editor, "e"); // just letter "e" | |
fake(editor, 48); // 0 | |
fake(editor, "leftArrow", ["ctrlKey", "shiftKey"]); |
// | |
// ViewController.m | |
// AVPlayerCaching | |
// | |
// Created by Anurag Mishra on 5/19/14. | |
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer | |
// | |
#import "ViewController.h" | |
#import <AVFoundation/AVFoundation.h> |
#import <Foundation/Foundation.h> | |
typedef void(^AsyncBlock)(dispatch_block_t completionHandler); | |
@interface AsyncBlockOperation : NSOperation | |
@property (nonatomic, readonly, copy) AsyncBlock block; | |
+ (instancetype)asyncBlockOperationWithBlock:(AsyncBlock)block; |
// | |
// ToneOutputUnit.swift | |
// | |
// This is a Swift 3 class (which should be instantiated as a singleton object) | |
// that can play a single tone of arbitrary tone and frequency on iOS devices | |
// using run-time sinewave synthesis and the Audio Unit v3 API with RemoteIO. | |
// | |
// Created by Ronald Nicholson [email protected] on 2/20/2016. | |
// revised 2016-Sep-08 for Swift 3 | |
// http://www.nicholson.com/rhn/ |
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,