Skip to content

Instantly share code, notes, and snippets.

View ricardopereira's full-sized avatar
🏠
Working from home

Ricardo Pereira ricardopereira

🏠
Working from home
View GitHub Profile
import UIKit
import XCPlayground
let items = ["One", "Two"]
let notificationsVC = UITableViewController()
class NotificationsDataSource: NSObject, UITableViewDataSource {
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
Test Case '-[AblySpec.RealtimeClientPresence Presence__subscribe__with_a_single_action_argument]' started.
2016-04-07 16:45:57.933 xctest[42245:6476208] receive <ARTProtocolMessage: 0x7f875355e250> {
count: 0,
id: (null),
action: 4,
channel: (null),
channelSerial: (null),
connectionId: VNo4H_EIR1,
connectionKey: 6b922!VNo4H_EIR1iDCa-l-22fe6b922,
connectionSerial: -1,
Test Case '-[AblySpec.RealtimeClientPresence Presence__subscribe__with_a_single_action_argument]' started.
2016-04-07 17:22:05.708 xctest[42813:6497859] INFO: ARTRealtime closed
2016-04-07 17:22:08.041 xctest[42813:6497859] DEBUG: (ARTRest.m:54) 0x7f8cb94ac7f0 alloc HTTP
2016-04-07 17:22:08.042 xctest[42813:6497859] DEBUG: (ARTAuth.m:44) validating ARTClientOptions: key=1aV3fw.6_Vqmg:ySZcu20M9U_b-bB_ token=(null) authUrl=(null) authMethod=GET hasAuthCallback=0
2016-04-07 17:22:08.042 xctest[42813:6497859] DEBUG: (ARTAuth.m:50) setting up auth method Basic (anonymous)
2016-04-07 17:22:08.042 xctest[42813:6497859] DEBUG: (ARTRest.m:67) initialized 0x7f8cb94d17a0
2016-04-07 17:22:08.043 xctest[42813:6497859] DEBUG: (ARTRealtime.m:106) initialized 0x7f8cb946a8d0
2016-04-07 17:22:08.043 xctest[42813:6497859] DEBUG: (ARTRealtime.m:194) 0x7f8cb946a8d0 transition to ARTRealtimeConnecting requested
2016-04-07 17:22:08.043 xctest[42813:6497859] DEBUG: (ARTWebSocketTransport.m:73) 0x7f8cb966fb70 alloc
2016-04-07 17:22:0
extension PHPhotoLibrary {
typealias PhotoAsset = PHAsset
typealias PhotoAlbum = PHAssetCollection
static func saveImage(image: UIImage, albumName: String, completion: (PHAsset?)->()) {
if let album = self.findAlbum(albumName) {
saveImage(image, album: album, completion: completion)
return
}
// The trick is to copy the DeviceSupport folder from the beta to the stable version.
cp -r /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.0\ \(14A5261u\) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
// Then restart Xcode. You might need to do that for every beta of iOS 10/Xcode 8.
#!/bin/bash
# based on (buggy on zsh)
#find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID
OLD_IFS=$IFS
IFS=$'\n'
BETA=""
@ricardopereira
ricardopereira / States-v2.md
Created July 29, 2016 13:33 — forked from andymatuschak/States-v3.md
A composable pattern for pure state machines with effects (draft v2)

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,

@ricardopereira
ricardopereira / Fastfile-example
Last active March 29, 2020 09:00
Automate some iOS development processes with Fastlane
fastlane_version "1.99.0"
REQUIRED_XCODE_VERSION = "7.3.1"
default_platform :ios
platform :ios do
before_all do |lane, options|
ENV["SLACK_URL"] = "https://hooks.slack.com/services/???"
end
fastlane_version "1.99.0"
REQUIRED_XCODE_VERSION = "7.3.1"
default_platform :ios
platform :ios do
desc "Run test suite"
lane :test do
scan project: "<APP>.xcodeproj"
end
# Mark FIXMEs and TODOs as warnings in DEBUG builds excluding the Pods directory.
if which XcodeIssueGenerator >/dev/null; then
XcodeIssueGenerator -b DEBUG -w "FIXME, TODO" -x "Pods/"
else
echo "warning: XcodeIssueGenerator is not installed."
fi