Skip to content

Instantly share code, notes, and snippets.

@noln
noln / created-date-from-filename.py
Last active November 15, 2025 18:49
Downloading videos from Google Photos in bulk results in the created date and last modified date being set to when the video was downloaded, not when it was created. This script takes a list of video files (as in the output of `ls -> files.txt` or suchlike), and if it recognises a timestamp in it, sets created date to that.
#!/usr/bin/env python3
"""
update_file_times.py
For every file in the current directory:
* If the name matches the GoPro pattern GX??????_#############.MP4
→ use the 13-digit millisecond epoch as the new timestamp.
* If the name matches the Pixel pattern PXL_YYYYMMDD_HHMMSSsss*.mp4
→ use YYYY-MM-DD HH:MM:SS.sss (milliseconds) as the new timestamp.
* Otherwise the file is skipped.
@noln
noln / MainActivity.kt
Last active July 17, 2024 14: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 December 30, 2024 08:11
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:
********************************************************************************