Skip to content

Instantly share code, notes, and snippets.

View bartekpacia's full-sized avatar
😎
just an enjoyer

Bartek Pacia bartekpacia

😎
just an enjoyer
View GitHub Profile
@bartekpacia
bartekpacia / file.m
Created April 26, 2023 22:21
$ clang -framework Foundation file.m -o file
#import <Foundation/Foundation.h>
@interface PatrolIntegrationTestRunner : NSObject
+ (NSString *)createMethodNameFromPatrolGeneratedGroup:(NSString *)dartTestGroup;
@end
@implementation PatrolIntegrationTestRunner
- (instancetype)init {
self = [super init];
@bartekpacia
bartekpacia / ContractsExtensions.kt
Last active April 22, 2023 20:21
patrol bundling stuff
fun DartTestGroup.listFlatDartFiles(): List<String> {
val files = mutableListOf<String>()
for (group in groupsList) {
files.addAll(group.listGroups())
}
return files.filter { it.endsWith(".dart") }
}
// Recursively lists groups in this group.
private fun DartTestGroup.listGroups(): List<String> {
@bartekpacia
bartekpacia / cmd_1
Last active July 22, 2023 16:51
Decode test-results.pb file generated by ./gradlew connectedAndroidTest
# display in protoc "text format" without keys
protoc --decode_raw < test-result.pb
@bartekpacia
bartekpacia / unsettling_test.dart
Last active October 26, 2022 09:28
Bug repro.
patrolTest(
'never settles when an invisible child of IndexedStack is requesting frames',
($) async {
await expectLater(
() async => $.pumpWidgetAndSettle(
MaterialApp(
home: Scaffold(
body: IndexedStack(
children: const [
Center(child: Text('first child')),
@bartekpacia
bartekpacia / UITests.swift
Last active October 14, 2022 07:04
Exploring what's possible with NSPredicate.
import XCTest
final class LandmarksUITests: XCTestCase {
let app = XCUIApplication()
override func setUpWithError() throws {
continueAfterFailure = false
app.launch()
}
PlayStore.enabled=true
abi.type=x86_64
avd.ini.displayname=Pixel 3 API 30
avd.ini.encoding=UTF-8
disk.dataPartition.size = 6442450944
fastboot.chosenSnapshotFile=
fastboot.forceChosenSnapshotBoot=no
fastboot.forceColdBoot=no
fastboot.forceFastBoot=yes
hw.accelerometer=yes
@bartekpacia
bartekpacia / extensions.dart
Created October 2, 2022 21:31
Useful localization-related extensions in Flutter.
extension BuildContextLocalizations on BuildContext {
Locale get locale => Localizations.localeOf(this);
String get languageCode => locale.toLanguageTag();
AppLocalizations get l10n => AppLocalizations.of(this)!;
List<Locale> get supportedLocales => AppLocalizations.supportedLocales;
List<Locale> get realSupportedLocales => AppLocalizationsX.supportedLocales;
func getNativeWidgets() throws {
for i in 0...10 {
let toggle = self.springboard.switches.element(boundBy: i)
let label = toggle.label as String
let accLabel = toggle.accessibilityLabel as String?
let ident = toggle.identifier
Logger.shared.i("index: \(i), label: \(label), accLabel: \(String(describing: accLabel)), ident: \(ident)")
}
}

How it looks like on leancode.co

void printNumber() {
  var number = 0;
  print('The number is $number');
}

How it should look like:

@bartekpacia
bartekpacia / upload_artifact
Created September 26, 2022 20:46
Shell script to easily upload a file to Azure Storage.
#!/usr/bin/env bash
set -euo pipefail
# upload_artifact uploads a file to Azure Storage.
#
# Usage:
#
# AZURE_SAS_TOKEN=SOME_TOKEN ./upload_artifact your_file.txt
artifact="${1:-}"