Skip to content

Instantly share code, notes, and snippets.

@noln
noln / MainActivity.kt
Last active April 23, 2024 11:33
Share an Image or Video file to Instagram, via MediaStore Uri
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 November 28, 2017 19:17
Alert dialog with Spinner in customView, using Anko (Kotlin)
// 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 March 22, 2024 16:43
Handy FFMPEG Commands for Quickly Processing GoPro Videos
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 August 27, 2022 19:25
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.
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 August 29, 2015 14:25
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).
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 July 19, 2015 14:16
Moves contents of current user's Downloads folder to Trash
#!/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 June 16, 2020 11:01
A basic anonymous AsyncTask with void return and no pre/post method.
new AsyncTask<Integer, Void, Void>(){
@Override
protected Void doInBackground(Integer... params) {
// main logic
return null;
}
}.execute(0);
@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);
}
/*
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:
********************************************************************************