Skip to content

Instantly share code, notes, and snippets.

@gb96
gb96 / DeRoboflowImages.ps1
Last active January 26, 2022 11:06
Roboflow exports image datasets containing names that have been suffixed with either hex encoded (or worse) guids.
# Windows PowerShell script for cleaning up terrible Roboflow dataset file names.
# One dataset I downloaded from Roboflow had duplicate images in the dataset, some with one kind of mangled name and duplicates
# with another kind of mangled name.
# Removing all the name mangling is an easy way to clean up the duplicates.
Get-ChildItem -Path . -Filter "*.rf.*" -Recurse | Rename-Item -NewName {$_.name -replace '_jpg\.rf\.[0-9a-zA-Z]+\.jpg','.jpg' }
# Any items that could not be renamed must be duplicates, so just remove them.
Get-ChildItem -Path . -Filter "*.rf.*" -Recurse | Remove-Item $_
@gb96
gb96 / PruneDataSet.ps1
Created January 23, 2022 00:30
YOLOv5 Training -- Remove all validation images larger than 80000 bytes and also corresponding labels
# Windows PowerShell script for removing validation images that meet some condition.
# Whenever an image is removed we also remove the corresponding annotations file
Get-ChildItem -Path .\valid\images -Recurse | ForEach-Object{
if ($_.Length -gt 80000){
Remove-Item ".\valid\images\$_" -Force
Remove-Item ".\valid\labels\$_".Replace(".jpg", ".txt") -Force
}
}
@gb96
gb96 / user.js
Last active September 26, 2019 07:15
UserScript for Google Play Console Order management form. Selects items for refund based on a hard-coded filter
// ==UserScript==
// @name Google Dev Select Orders to Refund
// @namespace https://hypearth.com/
// @version 1.16
// @description Google Play Console Order management form: Selects items for refund based on a hard-coded filter. Adds a Page+10 button
// @author gerg.bowering
// @include https://play.google.com/apps/publish/*
// @grant none
// ==/UserScript==
@gb96
gb96 / CountDownTimer.java
Last active September 17, 2019 00:42 — forked from bverc/CountDownTimer.java
Drop-in alternative for the Android CountDownTimer class, but [1] can cancel from within onTick, [2] can pause() and resume(), [3] can restart(long millisInFuture, long countDownInterval), [4] isCancelled() and isPaused(), [5] config(long, long)
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@gb96
gb96 / EventLog.java
Created February 16, 2018 00:46
Example of using java.util.logging (JUL) to write application log messages to a Swing JTextArea component
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
@gb96
gb96 / updates.SARL.io_composite_releases_content.patch
Created January 18, 2018 04:44
Changes to the content.xml within a mirrored version of http://updates.sarl.io/composite/releases/content.jar to allow installation in Eclipse Java Oxygen (4.7.1a) and newer
diff --git "a/SARL-mirror\\content.xml" "b/SARL-mirror2\\content.xml"
index be8b2dc..9db38f2 100644
--- "a/SARL-mirror\\content.xml"
+++ "b/SARL-mirror2\\content.xml"
@@ -1,8 +1,8 @@
-<?xml version='1.0' encoding='UTF-8'?>
+<?xml version='1.0' encoding='UTF-8'?>
<?metadataRepository version='1.1.0'?>
<repository name='SARL All In One (Releases)' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1'>
<properties size='2'>
/**
* For N=13 recursive swap() evaluates 0-based deck using nested switch.
* Inner switch is effectively inline version of one level of recursion.
* @see https://gist.github.com/826754
*
* @param v00
* @param v01
* @param v02
* @param v03
* @param v04
/**
* For N=13 recursive swap() evaluates TOPSWOPS for 0-based deck passed as args.
*
* @param v00
* @param v01
* @param v02
* @param v03
* @param v04
* @param v05
* @param v06