Skip to content

Instantly share code, notes, and snippets.

Working from home

Ricardo Pereira ricardopereira

Working from home
View GitHub Profile
ricardopereira / SubscriptionTests.swift
Created Jul 13, 2021
Using the SKTestSession in XCTest.
View SubscriptionTests.swift
import XCTest
import StoreKitTest
@available(iOS 14.0, *)
class SubscriptionTests: XCTestCase {
private var session: SKTestSession!
private var subscriptionsController: SubscriptionsController!
override func setUpWithError() throws {
ricardopereira /
Created Nov 12, 2020 — forked from killvetrov/
Android View Binding: base class to reduce boilerplate in Java
public abstract class BaseViewBindingFragment extends Fragment {
private Field bindingField;
private Method inflate;
try {
for (Field declaredField : this.getClass().getDeclaredFields()) {
if (ViewBinding.class.isAssignableFrom(declaredField.getType())) {
bindingField = declaredField;
View PasscodeKeychain.swift
// PasscodeKeychain.swift
// Example
// Created by Ricardo Pereira on 23/12/2016.
// Copyright © 2016 RP. All rights reserved.
import Foundation
ricardopereira / Transaction.swift
Created Jul 31, 2020 — forked from IanKeen/Example_Complex.swift
PropertyWrapper: @transaction binding for SwiftUI to make changes to data supporting commit/rollback
View Transaction.swift
import SwiftUI
import Combine
public struct Transaction<Value>: DynamicProperty {
@State private var derived: Value
@Binding private var source: Value
fileprivate init(source: Binding<Value>) {
View 2020-07-09 14:46:17.273356+0100-publish__with_a_Message_object__publishes_the_message_and_invokes_callback_with_success.log
Test Case '-[Ably_iOS_Tests.RestClientChannel publish__with_a_Message_object__publishes_the_message_and_invokes_callback_with_success]' started.
2020-07-09 14:46:17.273356+0100 xctest[31356:914686] DEBUG: (ARTAuth.m:163) RS:0x7fd39c9411a0 validating <ARTClientOptions: 0x7fd39c92d7f0> -
key: _tmp__nL2MA.1KbX9A:ooIOdVMRWxMziqOk;
token: (null);
authUrl: (null);
authMethod: GET;
hasAuthCallback: 0;
clientId: (null);
2020-07-09 14:46:17.280911+0100 xctest[31356:914686] DEBUG: (ARTAuth.m:169) RS:0x7fd39c9411a0 setting up auth method Basic (anonymous)
2020-07-09 14:46:17.281595+0100 xctest[31356:914686] DEBUG: (ARTRestChannel.m:129) RS:0x7fd39a7f2010 instantiating under 'test-5-CECA5948-5BF4-4FAC-8518-D7CBC2993F22-31356-00004E247C318640'
View Wallet.swift
import SwiftUI
import PlaygroundSupport
// constants
let cardWidth: CGFloat = 343
let cardHeight: CGFloat = 212
let spacing = 36
let animation = Animation.spring()
let cardColors = [
ricardopereira / InteractiveTransitionCollectionViewDeselection.m Animate table & collection view deselection alongside interactive transition (for iOS 11 and later)
View InteractiveTransitionCollectionViewDeselection.m
// UICollectionView Objective-C example
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject];
if (selectedIndexPath != nil) {
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
if (coordinator != nil) {
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
ricardopereira / GitHub-action-xctest-example.yml
Created Jun 30, 2020
GitHub Action example running Xcode tests and caches dependencies
View GitHub-action-xctest-example.yml
- develop
name: Build
name: Unit Tests
runs-on: macOS-latest
ricardopereira /
Created Jun 21, 2020 — forked from dpapathanasiou/
How to setup a usb wifi dongle on the Raspberry Pi Model A+


The Raspberry Pi Model A+ has just a single usb port, so getting the wifi configured has to done by editing /etc/network/interfaces from a command line prompt.

These instructions assume the Raspbian OS on the SD card, and a usb wifi adapter that supports the RTL8192cu chipset, since the current Raspbian has built-in support for it.

Before the first boot

  1. Put a keyboard in the usb slot
  2. Connect the HDMI slot to a monitor
View RealtimeClient__transport_should_guarantee_message_order.log
Test Case '-[Ably_iOS_Tests.RealtimeClient RealtimeClient__subscriber_should_receive_messages_in_the_same_order_in_which_they_have_been_sent]' started.
2020-05-09 09:26:14.188371+0100 xctest[39899:1401602] DEBUG: (ARTAuth.m:162) RS:0x7fe5bde17c60 validating <ARTClientOptions: 0x7fe5bde14370> -
key: _tmp_P6etwg.hMclYg:8eIR1wiiS15Cp1Oi;
token: (null);
authUrl: (null);
authMethod: GET;
hasAuthCallback: 0;
clientId: (null);
2020-05-09 09:26:14.188779+0100 xctest[39899:1401602] DEBUG: (ARTAuth.m:168) RS:0x7fe5bde17c60 setting up auth method Basic (anonymous)
2020-05-09 09:26:14.189331+0100 xctest[39899:1401602] DEBUG: RT:0x7fe5bde133d0 realtime is transitioning from 0 - Initialized to 1 - Connecting