(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
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,
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse
// Taken from http://PSPDFKit.com. This snippet is under public domain. | |
#define UIKitVersionNumber_iOS_7_0 0xB57 | |
BOOL PSPDFIsUIKitFlatMode(void) { | |
static BOOL isUIKitFlatMode = NO; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7. | |
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) { | |
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0; | |
} |
#!/usr/bin/env osascript -l JavaScript | |
function run() { | |
const VSCode = axApp('com.microsoft.VSCode'); | |
const window = axGet(VSCode, 'AXWindows')[0]; | |
return axWindowSetBounds(window, 200, 200, 1200, 1400); | |
} | |
/** |
type Json = | |
| Null | |
| Bool of bool | |
| Number of float | |
| String of string | |
| Array of Json list | |
| Object of (string * Json) list | |
type Bracket = Open | Close |
/** | |
Provides the ability to verify key paths at compile time. | |
If "keyPath" does not exist, a compile-time error will be generated. | |
Example: | |
// Verifies "isFinished" exists on "operation". | |
NSString *key = SQKeyPath(operation, isFinished); | |
// Verifies "isFinished" exists on self. |
{ | |
"People" : [ | |
"😀", | |
"😃", | |
"😄", | |
"😁", | |
"😆", | |
"😅", | |
"😂", | |
"🤣", |
namespace System.Text.Json | |
open System | |
open System.Collections.Generic | |
open System.Text.Json.Serialization | |
// Converts Option<T> to/from JSON by projecting to null or T | |
type OptionValueConverter<'T>() = | |
inherit JsonConverter<'T option>() |
;; Provided by Sebastian Urban | |
;; More information at https://idiocy.org/emacs-fonts-and-fontsets.html | |
(set-fontset-font "fontset-default" 'adlam "Noto Sans Adlam") | |
(set-fontset-font "fontset-default" 'anatolian "Noto Sans Anatolian Hieroglyphs") | |
(set-fontset-font "fontset-default" 'arabic "Noto Sans Arabic") | |
(set-fontset-font "fontset-default" 'aramaic "Noto Sans Imperial Aramaic Regular") | |
(set-fontset-font "fontset-default" 'armenian "Noto Sans Armenian") | |
(set-fontset-font "fontset-default" 'avestan "Noto Sans Avestan") | |
(set-fontset-font "fontset-default" 'balinese "Noto Sans Balinese") |