Skip to content

Instantly share code, notes, and snippets.

@slashdotdash
slashdotdash / README.md
Last active March 11, 2019 10:03
Dealing with eventually consistent read model projections in Commanded

Dealing with eventually consistent read model projections in Commanded

Example

with {:ok, version} <- Router.dispatch(command, include_aggregate_version: true),
     {:ok, projection} <- wait_for_projection_version(ExampleProjection, uuid, version) do   

  # ... safely use up-to-date read model projection at expected version
 
@k3zi
k3zi / PSPDFUIKitMainThreadGuard
Last active August 29, 2015 14:03
Automatically kick all UIKit calls to Main Thread
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
#define PROPERTY(propName) NSStringFromSelector(@selector(propName))
// A better assert. NSAssert is too runtime dependant, and assert() doesn't log.
// http://www.mikeash.com/pyblog/friday-qa-2013-05-03-proper-use-of-asserts.html
// Accepts both:
@andrewmichaelson
andrewmichaelson / PSPDFUIKitMainThreadGuard.m
Last active March 15, 2016 09:36 — forked from steipete/PSPDFUIKitMainThreadGuard.m
Modified to work with AppKit on OS X instead of UIKit on iOS.
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
#import <Foundation/Foundation.h>
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active May 27, 2024 12:11
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@mattt
mattt / uiappearance-selector.md
Last active June 4, 2024 13:28
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@steipete
steipete / gist:2255253
Created March 30, 2012 21:25
ISO 8601 parsing
+ (NSDate *)dateFromISO8601String:(NSString *)iso8601 {
if (!iso8601) {
return nil;
}
const char *str = [iso8601 cStringUsingEncoding:NSUTF8StringEncoding];
char newStr[24];
struct tm tm;
size_t len = strlen(str);
@vhazrati
vhazrati / PullApplicationActorLess.scala
Created December 19, 2011 10:00
Pulling on a socket
object PullApplicationActorLess extends App {
val TOTAL_MESSAGES = 1000000
val diagnostics = actorOf(new Diagnostics.DiagnosticsActor).start
var context: ZMQ.Context = null
var pullSocket: ZMQ.Socket = null
context = ZMQ.context(1)
pullSocket = context.socket(ZMQ.PULL)
pullSocket.connect("tcp://127.0.0.1:5555")
@martijnthe
martijnthe / Xcode4TestFlightintegration.sh
Created November 19, 2011 15:47 — forked from fictorial/Xcode4TestFlightintegration.sh
ReWrite: "Xcode 4 scheme Archive step Post-script for automatic TestFlight build uploading. See the blog post here: http://developmentseed.org/blog/2011/sep/02/automating-development-uploads-testflight-xcode"
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
# Inspired by original script by incanus:
# https://gist.github.com/1186990
#
# Rewritten by martijnthe:
# https://gist.github.com/1379127
#
@douglasjarquin
douglasjarquin / homebrew-update.sh
Created June 14, 2011 17:58
Update outdated Homebrew packages
brew upgrade `brew outdated | awk {'print $1'} | xargs`