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
final _declarativeKotlinPluginPatterns = <RegExp>[
RegExp('^\\s*id\\s*\\(?\\s*[\'"]kotlin-android[\'"]\\s*\\)?\\s*\$'),
RegExp(
'^\\s*id\\s*\\(?\\s*[\'"]org.jetbrains.kotlin.android[\'"]\\s*\\)?\\s*\$'),
];
final lines = <String>[
'id "kotlin-android"',
'id("kotlin-android")',
'id ( "kotlin-android" ) ',
@bartekpacia
bartekpacia / .cirrus.yaml
Created August 22, 2024 18:27
cirrus ci config draft for maestro
pipe:
name: Build and validate
steps:
- image: ghcr.io/cirruslabs/android-sdk:34
#image: gradle:7.6.4-jdk11-alpine
build_script: |
sudo apt-get update
sudo apt-get install -y nodejs npm
./gradlew :maestro-cli:installDist
- image: eclipse-temurin:8-jre-alpine
@bartekpacia
bartekpacia / script.sh
Created August 20, 2024 00:52
Trying to automatically find the version of classfiles in Android SDK. See also: https://stackoverflow.com/q/78890085/7009800
#!/usr/bin/env bash
set -euo pipefail
for file in *.zip; do
version="$(echo "$file" | cut -d '-' -f 4 | cut -d '.' -f 1)"
new_dir="android-clt-$version"
echo "extracting file $file into $new_dir"
unzip -o -d "android-clt-$version" "$file" >/dev/null 2>&1
@bartekpacia
bartekpacia / concurrency_1.kt
Last active August 3, 2024 00:58
Tour of Go (Concurrency) but in Kotlin Coroutines
import kotlinx.coroutines.*
suspend fun say(s: String) {
for (i in 1..5) {
delay(100L)
println(s)
}
}
fun main() = runBlocking {
@bartekpacia
bartekpacia / main.go
Last active July 24, 2024 22:04
Verifying if HMAC digests match in Golang.
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"fmt"
"strings"
)
@bartekpacia
bartekpacia / Foo.jmm
Last active April 19, 2024 05:02
Example JMM files
class Foo {
public int constInstr() {
return 0;
}
public int add(int a, int b) {
int c;
c = a + this.constInstr();
return 0;
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
import 'package:meta/meta.dart';
import 'package:test/test.dart';
// ignore: depend_on_referenced_packages
import 'package:test_api/src/backend/invoker.dart';
// Input:
const String requestedTest = 'testA';
// Global state:
@bartekpacia
bartekpacia / callbacks_test.dart
Created September 21, 2023 11:40
A mini-example of executing a single Dart test with its lifecycle callbacks.
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/src/extensions.dart';
// ignore: depend_on_referenced_packages
import 'package:test_api/src/backend/invoker.dart';
const String requestedTest = 'groupA testA';
String get currentTest => Invoker.current!.fullCurrentTestName();
void main() {
@bartekpacia
bartekpacia / intro_permissions_1.dart
Last active September 19, 2023 14:20
Flutter Silesia #6 snippets
PatrolTester $;
$.native.grantPermissionWhenInUse()
$.native.grantPermissionOnlyThisTime();
$.native.denyPermission();