Skip to content

Instantly share code, notes, and snippets.

View JakeSteam's full-sized avatar
🤖

Jake Lee JakeSteam

🤖
View GitHub Profile
@JakeSteam
JakeSteam / Icons.kt
Last active December 23, 2024 21:32
compose-material-dialogs forwardport for Compose 1.7.1+
/*
* Copyright 2020 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
@JakeSteam
JakeSteam / MyFragment.kt
Last active January 9, 2025 11:28
Remotely configurable in-app Play Store review prompt in Kotlin
class MyFragment {
val navToBookings: () -> Unit = {
findNavController().navigate(MyFragmentDirections.toBookings())
}
fun eventHandler(event: TicketConfirmationEvents) {
when (event) {
is TicketConfirmationEvents.OnLookAtMyTicket -> {
viewModel.onLookAtMyTicket(navToBookings)
@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)
@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 / 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 / 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 / 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">
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 / 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.
@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;