Skip to content

Instantly share code, notes, and snippets.

View fkirc's full-sized avatar

fk fkirc

  • Austria
View GitHub Profile
@fkirc
fkirc / InputStreamToString.java
Last active July 3, 2019 11:15
Java (JDK only): Efficiently convert InputStream to String
private static String inputStreamToString(final InputStream is) throws IOException {
final InputStreamReader ir = new InputStreamReader(is, "UTF-8");
final StringBuilder sb = new StringBuilder();
final char[] buf = new char[1024];
int n;
while ((n = ir.read(buf)) != -1) {
sb.append(buf, 0, n);
}
return sb.toString();
}
@fkirc
fkirc / git_repo_to_zip.sh
Created September 23, 2019 14:09
git repo to zip
#!/usr/bin/env bash
set -x
set -e
usage() {
echo "Usage: $0 <output name> <git repo path>"
exit 1
}
[[ $# -eq 2 ]] || {
#!/usr/bin/python
import sys
def read_file(f):
print(f.read())
def main():
@fkirc
fkirc / JAVA_HOME locations
Last active December 19, 2019 12:50
JAVA_HOME locations
macOS Android Studio JDK:
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
@fkirc
fkirc / checkout_all.py
Created January 16, 2020 21:09
Small Python template for shell operations
import os
import subprocess
def sh(cmd):
print('sh: ' + cmd)
ret = subprocess.run(cmd, shell=True, env=os.environ, executable='/bin/bash')
if ret.returncode != 0:
exit(ret.returncode)
@fkirc
fkirc / NonFatalAbortTree.kt
Created March 26, 2020 22:32
Make Android UI tests fail if an error gets logged to Timber
import android.util.Log
import androidx.test.espresso.Espresso
import org.junit.Assert
import timber.log.Timber
/**
* During UI tests, we want to fail the test immediately if any "non-fatal error" happens.
* The purpose of non-fatal errors is to inform as about production failures without crashing the entire app.
*/
object NonFatalAbortTree: Timber.Tree() {
{
"compilerOptions": {
"target": "es2018",
"lib": [
"es6",
"dom",
"dom.iterable",
"esnext",
"es2018"
],
@fkirc
fkirc / .eslintrc.js
Last active September 17, 2020 11:22
ESLint React configuration (combined with Prettier + WebStorm)
module.exports = {
extends: [
"react-app",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
"prettier/react",
],
plugins: [
"simple-import-sort"
@fkirc
fkirc / ci.yml
Last active October 2, 2020 12:51
Capacitor Cross-platform GitHub Action: npm + Android
name: CI
on:
push:
workflow_dispatch:
jobs:
pre_job:
runs-on: ubuntu-latest
# Map a step output to a job output
@fkirc
fkirc / ci.yml
Last active June 27, 2022 10:26
npm GitHub Action - Test automatically. Trigger releases manually.
name: CI
on:
push:
branches:
- '**'
workflow_dispatch:
inputs:
release:
description: 'Release'