Skip to content

Instantly share code, notes, and snippets.

View JakeSteam's full-sized avatar
🤖

Jake Lee JakeSteam

🤖
View GitHub Profile
@JakeSteam
JakeSteam / Car.kt
Last active September 4, 2024 17:15
How to extract a Room list column into a new linked table, migrating data https://blog.jakelee.co.uk/how-to-extract-a-room-list-column-into-a-new-linked-table-migrating-data/
class Car(
@Embedded
val metadata: CarMetadata,
@Relation(
parentColumn = "id", // The name of the CarMetadata ID field
entityColumn = "carId" // The name of the Component's car ID field
)
var components: List<Component>
)
@JakeSteam
JakeSteam / settings.ini
Created March 8, 2022 23:14
IrfanView replace image with black background and filename
; UNICODE FILE - edit with care ;-)
[Batch]
AdvCrop=0
AdvCropX=0
AdvCropY=0
AdvCropW=0
AdvCropH=0
AdvCropC=0
AdvResize=0
@JakeSteam
JakeSteam / maze.as
Created January 5, 2023 22:20
"Scary Maze Game" decompiled
package
{
import com.google.ads.instream.api.AdErrorEvent;
import com.google.ads.instream.api.AdEvent;
import com.google.ads.instream.api.AdLoadedEvent;
import com.google.ads.instream.api.AdSizeChangedEvent;
import com.google.ads.instream.api.AdsLoadedEvent;
import com.google.ads.instream.api.AdsLoader;
import com.google.ads.instream.api.AdsManager;
import com.google.ads.instream.api.AdsManagerTypes;
@JakeSteam
JakeSteam / coins.svg
Created February 1, 2023 09:51
Cleaning up an SVG for Minima 3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Red Page
Red Page (dirty)
Yellow Page
Yellow Page (dirty)
Green Page
Green Page (dirty)
Blue Page
Blue Page (dirty)
Pink Page
Pink Page (dirty)
@JakeSteam
JakeSteam / calendar.html
Last active October 11, 2024 17:41
Jekyll / Liquid calendar with custom events
<div class="calendar-container">
{% assign current_year = 'now' | date: '%Y' %}
{% for month in (1..12) %}
<!-- Month prep -->
{% assign month_str = month | prepend: '0' | slice: -2, 2 %}
{% assign month_start_date = current_year | append: '-' | append: month_str | append: '-01' %}
{% assign month_start_timestamp = month_start_date | date: "%s" %}
{% assign first_day_found = false %}
<div class="calendar-month">
@JakeSteam
JakeSteam / clean_stumbleupon_metadata.py
Last active October 19, 2024 21:10
Bulk downloading from Archive.org's Wayback Machine and extracting data into CSVs (e.g. StumbleUpon)
import pandas as pd
import csv
df = pd.read_csv('data-parsed/parsed.csv')
df = df.drop_duplicates(subset='id', keep='last')
df.to_csv('data-parsed/parsed-cleaned.csv', index=False, quoting=csv.QUOTE_NONNUMERIC)
@JakeSteam
JakeSteam / ForceUpdateHandler.kt
Last active November 9, 2024 22:42
Forcing app updates on Android using Google's in-app update library https://blog.jakelee.co.uk/implementing-google-in-app-updates-for-android/
// Adapted from https://developer.android.com/guide/playcore/in-app-updates/kotlin-java
class ForceUpdateHandler @Inject constructor(
private val abTestManager: ABTestManager // Optional
) {
fun forceUpdateIfNeeded(activity: ComponentActivity) {
// Optional, an optimisation / safety check
val minimumAllowedVersion = abTestManager.remoteConfigLong(FirebaseRemoteConfigKeys.minimum_version)
if (BuildConfig.VERSION_CODE >= minimumAllowedVersion) {
return
@JakeSteam
JakeSteam / home.html
Created November 30, 2024 18:03
How to add automatic webp post banners to Jekyll for faster load times
...
<a class="post-link" href="{{ post.url | relative_url }}">
{% include custom/webp.html path=post.image alt=post.title %}
</a>
...
@JakeSteam
JakeSteam / artist_parse.py
Last active December 7, 2024 20:42
Script to parse all years & artists from "by artist1, artist2, artist3" in GitHub's Octodex feed
import xml.etree.ElementTree as ET
from collections import Counter
import re
# Source: https://octodex.github.com/atom.xml
tree = ET.parse('atom.xml')
root = tree.getroot()
artists = re.findall(r' by ([\w\s,]+)\n', ET.tostring(root, encoding='unicode', method='text'), re.IGNORECASE)