Skip to content

Instantly share code, notes, and snippets.

@tir38
tir38 / resize
Last active April 21, 2023 18:58
Resize and sort images for two digital picture frames: landscape and portrait
#!/bin/bash
process() {
OUTPUT_DIR="/Users/jason/Desktop/output"
mkdir -p $OUTPUT_DIR
# Image magick doesn't give me the chance to check exif *before* conversion
# so auto-orient into temp and then move to appropriate directory
TEMP="$OUTPUT_DIR/temp.png"
# the \> will prevent upsample
```
2020-06-08T17:20:08.414-0400 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.google.protobuf:protobuf-bom:3.10.0' in resolver cache 'Google'
2020-06-08T17:20:08.414-0400 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.google.protobuf:protobuf-bom:3.10.0' in resolver cache 'Google'
2020-06-08T17:24:59.936-0400 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.google.code.gson:gson:2.8.5' in resolver cache 'Google'
2020-06-08T17:24:59.956-0400 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.google.protobuf:protobuf-java:3.10.0' in resolver cache 'Google'
2020-06-08T17:24:59.957-0400 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModule
mport android.media.AudioFormat
import android.media.AudioRecord
import android.media.MediaRecorder
class AudioRecorder {
private val minBufferSize: Int = AudioRecord.getMinBufferSize(SAMPLE_RATE_HZ, AUDIO_RECORDING_FORMAT, AUDIO_ENCODING)
private var audioRecord: AudioRecord? = null
fun startRecording() {
@tir38
tir38 / example.kt
Last active February 6, 2020 16:35
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
/*
What is blockingSubscribe() doing?
1. processing items on computation thread; not blocking main thread
2. processing items on computation thread; blocking main thread until terminal event
3. processing items on main thread; but not actually blocking main thread
4. processing items on main thread and blocking main thread until terminal event
@tir38
tir38 / README.md
Last active January 21, 2020 17:54
Find number of days of RescueTime data *above* a threshold. Example: How many days in 2019 did I work more than 15 minutes.

Find number of days of RescueTime data above a threshold.

Example: How many days in 2019 did I work more than 15 minutes?

$ ruby script.rb

Processed data for 281 days;
Found 259 above threshold of 15 minutes of activity.
Task :app:execFlank
AndroidArgs
gcloud:
results-bucket: test-lab-xxx
results-dir: null
record-video: false
timeout: 30m
async: false
results-history-name: null
# Android gcloud
... user triggered event to start download
499 14371-14371/com.example D/MainActivity: About to nav to on-demand feature
507 14371-14371/com.example I/PlayCore: UID: [10423] PID: [14371] SplitInstallListenerRegistry : registerListener
524 14371-14371/com.example I/PlayCore: UID: [10423] PID: [14371] SplitInstallService : startInstall([ondemandfeature],[])
527 14371-14683/com.example I/PlayCore: UID: [10423] PID: [14371] SplitInstallService : Initiate binding to the service.
540 14371-14371/com.example I/PlayCore: UID: [10423] PID: [14371] SplitInstallService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.splitinstallservice.SplitInstallService})
541 14371-14683/com.example I/PlayCore: UID: [10423] PID: [14371] SplitInstallService : linkToDeath
544 22063-22075/? I/Finsky: [163] uxv.a(48): Start install for package: com.example
567 22063-14685/? I/Finsky: [481] dwq.<init>(25): com.example is installed but certifica
#!/usr/bin/env bash
echo "restarting with fresh gradle daemon..."
./gradlew --stop
./gradlew clean
./gradlew --profile --offline --rerun-tasks app:assembleDebug
# Change "--profile --offline" to --scan to use Gradle's scan tool https://guides.gradle.org/creating-build-scans/
# Any build errors while profiling? remove --offline, try again, then re-add --offline
@tir38
tir38 / GattDebugger.java
Last active May 16, 2019 21:12
We were badly using reflection to spy on android.bluetooth.BluetoothGatt and see while it would fail to write. Don't do this. Instead vote to have methods added/updated to use public API https://issuetracker.google.com/issues/132907122
package com.example
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import java.lang.reflect.Field;
@tir38
tir38 / MyPlugin.kt
Last active May 11, 2019 07:36
Creating plugin (located in buildSrc/src/main/kotlin/com/example)
package com.example
import org.gradle.api.Plugin
import org.gradle.api.Project
// :eyes: why is A/S saying 'android' is unresolved reference??
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.LibraryPlugin
class MyPlugin : Plugin<Project> {