Skip to content

Instantly share code, notes, and snippets.

View Jason-Abbott's full-sized avatar

Jason Abbott Jason-Abbott

View GitHub Profile
@sobri909
sobri909 / App.swift
Created December 7, 2022 03:16
Matt's minimalist GRDB CloudKit sync layer
// fragment of main app file, to doing manual CloudKit fetches on appear,
// because can't always rely on CloudKit subscription being timely
@main
struct LifeBalanceApp: App {
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
TodayTab().environmentObject(Session.highlander)
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active June 9, 2024 19:08
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@PauloLuan
PauloLuan / GetExternalSdCardPath.java
Last active October 31, 2022 07:02
how to get the external sd card path on android.
public static String getExternalSdCardPath() {
String path = null;
File sdCardFile = null;
List<String> sdCardPossiblePath = Arrays.asList("external_sd", "ext_sd", "external", "extSdCard");
for (String sdPath : sdCardPossiblePath) {
File file = new File("/mnt/", sdPath);
if (file.isDirectory() && file.canWrite()) {
@domenic
domenic / promise-retryer.js
Last active September 16, 2023 02:43
Generalized promise retryer
"use strict";
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances.
// If one of those happens, we want to retry until it doesn't.
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects;
// it has no synchronous behavior (e.g. throwing).
function dontGiveUp(f) {
return f().then(
undefined, // pass through success