Skip to content

Instantly share code, notes, and snippets.

View AndrewReitz's full-sized avatar

Andrew Reitz AndrewReitz

View GitHub Profile
@AndrewReitz
AndrewReitz / main.py
Created March 10, 2022 15:54
Python gradle.kts to libs.version.toml script
import pyperclip
import time
import re
reg = re.compile("\"[A-Za-z0-9:-]+\"")
while True:
inp = pyperclip.paste()
t = reg.findall(inp)
@AndrewReitz
AndrewReitz / jpSearch.sh
Last active August 20, 2020 13:39
Simple Script for doing quick search for language learning
#!/usr/bin/env bash
PROGNAME="$(basename "$0")"
usage() {
echo "$PROGNAME: usage: $PROGNAME name" >&2
exit 1
}
results_open() {
{
"meta": { "theme": "flat" },
"basics": {
"name": "Andrew Reitz",
"label": "Android Developer",
"picture": "",
"email": "[email protected]",
"website": "http://andrewreitz.com",
"summary": "Passionate Android Developer.",
"location": {
@AndrewReitz
AndrewReitz / jvm-args-abi.scenarios
Created May 20, 2019 16:49
JVM Args profile scenario file for Plaid
default-scenarios = [
"abi-assemble-default",
"abi-assemble-2gb",
"abi-assemble-4gb",
"abi-assemble-6gb",
"abi-assemble-8gb"
]
abi-assemble-default {
tasks = ["assembleDebug"]
@AndrewReitz
AndrewReitz / profiler.scenarios
Created May 13, 2019 19:20
Sample Scenarios
config {
tasks = ["help"]
}
cleanAssemble {
tasks = ["assemble"]
cleanup-tasks = ["clean", "cleanBuildCache"]
}
abiAssemble {
@AndrewReitz
AndrewReitz / build.gradle
Created May 5, 2019 15:28
Example of dependencies in groovy gradle file
dependencies {
implementation("com.jakewharton.rxbinding2:rxbinding:2.2.0")
implementation("com.jakewharton:process-phoenix:2.0.0")
implementation("com.jakewharton.timber:timber:4.7.1")
implementation("com.jakewharton.byteunits:byteunits:0.9.1")
debugImplementation("com.readystatesoftware.chuck:library:1.1.0")
releaseImplementation("com.readystatesoftware.chuck:library-no-op:1.1.0")
buildFlavorOneImplementation("com.squareup.leakcanary:leakcanary-android:1.6.3")
@AndrewReitz
AndrewReitz / settings.gradle.kts
Last active May 3, 2019 01:05
My settings.gradle.kts for my kotlin raytracing project
include(
"raytracer-core",
"raytracer-math",
"raytracer-console",
"raytracer-parsing"
)
rootProject.name = "kotlin-raytracer"
rootProject.children.forEach {
@AndrewReitz
AndrewReitz / LazySetters.kt
Created March 28, 2019 18:30
Like lazy in kotlin but you can also have setters.
fun <T: Any> lazy(initializer: () -> T): LazySetter<T> = LazySetter(initializer)
class LazySetter<T: Any>(private val initializer: () -> T) {
private var _value: T? = null
var value: T
get() = _value ?: initializer()
set(value) { _value = value }
}
inline operator fun <reified T: Any> LazySetter<T>.setValue(thisRef: Any?, property: KProperty<*>, value: T) {
@AndrewReitz
AndrewReitz / serialVersionTest.kts
Created March 14, 2019 16:41
create two giant projects one with and one without serialVersionUID and benchmark compilation of them
#!/bin/bash
//usr/bin/env echo '
/**** BOOTSTRAP kscript ****\'>/dev/null
command -v kscript >/dev/null 2>&1 || curl -L "https://git.io/fpF1K" | bash 1>&2
exec kscript $0 "$@"
\*** IMPORTANT: Any code including imports and annotations must come after this line ***/
import java.io.File
import java.util.concurrent.TimeUnit
@AndrewReitz
AndrewReitz / app.js
Created November 19, 2018 22:00
Cadence Speed Sensor
const noble = require('noble');
noble.on('stateChange', state => {
if (state === 'poweredOn') {
noble.startScanning(['1816']);
} else {
noble.stopScanning();
}
});