Skip to content

Instantly share code, notes, and snippets.

@onyxmueller
onyxmueller / slack_spotify.sh
Last active March 24, 2020 14:29
Bash script to set current Spotify song as Slack status.
#!/bin/bash
APIKEY="From Here https://api.slack.com/custom-integrations/legacy-tokens"
trap onexit INT
function reset() {
echo 'Resetting status'
curl -s -d "payload=$json" "https://slack.com/api/users.profile.set?token="$APIKEY"&profile=%7B%22status_text%22%3A%22%22%2C%22status_emoji%22%3A%22%22%7D" > /dev/null
}
@onyxmueller
onyxmueller / brew_update.sh
Created August 30, 2018 03:39
A shell script that cleans up and updates Homebrew.
#!/bin/sh
# setup path
PATH=/usr/local/bin:/usr/bin:/bin
# remove stale/old files and update Homebrew
brew cleanup | logger -s
brew cask cleanup | logger -s
brew update | logger -s
@onyxmueller
onyxmueller / DownloadProgressUpdater.kt
Last active September 22, 2023 15:14
An Android Kotlin class to track and update download progress by the DownloadManager.
/**
* Tracks download of a DownloadManager job and reports progress.
*/
internal class DownloadProgressUpdater(private val manager: DownloadManager, private val downloadId: Long, private var downloadProgressListener: DownloadProgressListener?) : Thread() {
private val query: DownloadManager.Query = DownloadManager.Query()
private var totalBytes: Int = 0
interface DownloadProgressListener {
fun updateProgress(progress: Long)
}
@onyxmueller
onyxmueller / MobileOnlyNetworkTest.java
Created June 1, 2017 15:23
An example Java class file demonstrating how to create a mobile/cellular-only OkHttp based network.
public class MobileOnlyNetworkTest {
private static final int TIMEOUT_SECONDS = 30;
public Test(Context context) {
Network network = getCellNetwork(context);
if (network != null) {
OkHttpClient client = getNetworkClient(network);
}
}
@onyxmueller
onyxmueller / severity_order_of_fixes_for_AS.txt
Created May 18, 2017 18:50
Severity Order of Fixes for Android Studio
./gradlew clean
./gradlew --stop
rm -r .gradle
Restart Android Studio
Invalidate caches
Restart computer
@onyxmueller
onyxmueller / zopfli_compression_notes.txt
Last active March 17, 2017 03:36
Add ZopFli Compression To Android Release APKs
// Apply ZopFli compression to an APK at the command-line
zipalign -z 4 infile.apk outfile.apk
// Add the following to your build.gradle
//add zopfli to variants with release build type
android.applicationVariants.all { variant ->
if (variant.buildType.name == 'release') {
variant.outputs.each { output ->
@onyxmueller
onyxmueller / example_circle.yml
Last active November 16, 2015 18:30
Example CircleCI Configuration For Building a Fork of Google's CastVideos-android Repo
# This is an example CircleCI configuration file for building a fork of
# Google's CastVideos-android repo (https://github.com/googlecast/CastVideos-android)
#
# To try it:
# 1) Google's CastVideos-android repo: https://github.com/googlecast/CastVideos-android
# 2) Copy this file to your fork.
# 3) Add your fork as a project to CircleCI
general:
branches:
@onyxmueller
onyxmueller / strip_android_png_metadata.sh
Last active October 25, 2015 11:13
A Bash shell script to strip metadata from Android PNG resources.
#!/bin/bash
#
# Get rid of 'libpng warning: iCCP: Not recognizing known sRGB profile that has been edited' compilation warnings
# from AAPT by running this Bash shell script in the root folder of your Android project. This will use exiftool
# to remove PNG metadata (created by tools like Photoshop) from your Android project's PNG resources.
#
# NOTE: exiftool needs to be installed and in your path. Install it using homebrew or some other method.
#
@onyxmueller
onyxmueller / strip_google_play_services.gradle
Last active August 29, 2015 14:09
Strip Google Play Services Packages
import groovy.transform.Field
// This is a drop-in Gradle script that allows you to easily strip out the packages you don't need
// from the Google Play Services library. The script will keep track of previous runs to prevent
// restripping each time you build.
// HOW TO USE THIS
//
// 1) Download/copy this strip_google_play_services.gradle file into the same location of your app's
// build.gradle file.
package com.yelp.android.ui.widgets;
import com.yelp.android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;