Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt noln

View GitHub Profile
@noln
noln / MainActivity.kt
Last active May 30, 2020
Share an Image or Video file to Instagram, via MediaStore Uri
View MainActivity.kt
import android.annotation.SuppressLint
import android.content.*
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.MediaStore
import android.util.Log
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import java.io.File
@noln
noln / gist:d33e432158a8240d2fb7cd5850092933
Created Nov 28, 2017
Alert dialog with Spinner in customView, using Anko (Kotlin)
View gist:d33e432158a8240d2fb7cd5850092933
// Items for spinner
val items = arrayOf("One", "Two", "Three", "Four", "Five")
// Alert with a spinner
alert("Example Alert") {
title = "Example Alert"
customView {
verticalLayout {
spinner {
adapter = ArrayAdapter(ctx, android.R.layout.simple_spinner_dropdown_item, countries)
@noln
noln / ffmpeg_commands.txt
Last active Aug 21, 2018
Handy FFMPEG Commands for Quickly Processing GoPro Videos
View ffmpeg_commands.txt
1) Concatenate a list of videos into one
ffmpeg -f concat -safe 0 -i tojoin.txt -c copy output.mp4
// Format of tojoin.txt:
file 'file0.MP4'
file 'file1.MP4'
file 'etc..
2) Scale down 4k video to
@noln
noln / MainActivity.java
Last active Apr 8, 2020
A basic activity that listens to zen_mode state (Android's "do not disturb" volume/vibration muting feature) and dumps the current value to log. There are two ways included; the first is an observer and doesn't work in every case (I think there's a separate preference for priority messages), the second may is a manual check by hitting a button.
View MainActivity.java
import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@noln
noln / failoverScreenshot.java
Last active Aug 29, 2015
Using this instead of straight Spoon.screenshot(..) until issue identified in https://github.com/square/spoon/issues/151 is resolved. Extremely noddy for a Gist, but works with my library-builder script (which I might open source when it's done :-P).
View failoverScreenshot.java
private void failoverScreenshot(String desc) {
try {
Spoon.screenshot(getActivity(), desc);
}
catch (IllegalArgumentException e) {
Log.v(TAG, "Handled erroneous Spoon-Client screenshot exception.");
}
@noln
noln / DownloadsToTrash
Created Jul 19, 2015
Moves contents of current user's Downloads folder to Trash
View DownloadsToTrash
#!/bin/bash
# b.nelissen
# move contents of downloads folder to trash (I want a clean downloads folder every time I login)
mv ~/Downloads/* ~/.Trash/
@noln
noln / gist:4853bfe0908f87dee41f
Last active Jun 16, 2020
A basic anonymous AsyncTask with void return and no pre/post method.
View gist:4853bfe0908f87dee41f
new AsyncTask<Integer, Void, Void>(){
@Override
protected Void doInBackground(Integer... params) {
// main logic
return null;
}
}.execute(0);
View gist:9d5424cb4953e8c29c22
@Override
public void onPropertiesChanged(Bundle properties) {
super.onPropertiesChanged(properties);
mLowBitAmbient = properties.getBoolean(PROPERTY_LOW_BIT_AMBIENT, false);
mBurnInProtection = properties.getBoolean(PROPERTY_BURN_IN_PROTECTION,
false);
}
View gist:77503c4d6734429220ee
/*
First-off, huge thanks both Fenix and Buffer teams for the apps, I use them both
every day, and think they're brilliant! The only issue I have is that they don't
currently like to talk to eachother...if they did? That would be great!
Here's my analysis on why they currently don't:
********************************************************************************
You can’t perform that action at this time.