Skip to content

Instantly share code, notes, and snippets.

Working from home

Chris Jones cmsj

Working from home
View GitHub Profile
cmsj / ContentView.swift
Created Aug 21, 2020
Extending someone else's Swift enum to make it more friendly for a SwiftUI Picker
View ContentView.swift
// ContentView.swift
// EnumExtensionPicker
// Created by Chris Jones on 21/08/2020.
import SwiftUI
enum Strategy {
cmsj / gist:23935c42a10cf10c9ea0d544b8c31f65
Created Aug 4, 2020
Google Script mail header example
View gist:23935c42a10cf10c9ea0d544b8c31f65
function processInbox() {
// process all recent threads in the Inbox (see comment to this answer)
var threads ="from:( newer_than:1d");
Logger.log("Got threads: " + threads.length);
for (var i = 0; i < threads.length; i++) {
View gist:ccc7e7b60661a705c1003788436382fe
// Configuration data
// Each config should have the following keys:
// * age_min: maps to 'older_than:' in gmail query terms.
// This is how old you want matching emails to be before they are archived.
// * age_max: maps to 'newer_than:' in gmail query terms.
// This is how far back in history you want to search, to find emails to archive.
// It's useful to set fairly long for your first run, but after that set it to a
// reasonably low value (don't expect Google to search your entire email archive
// every time this script runs!)
// * query: freeform gmail query terms to match against
cmsj / ContentView.swift
Created Jun 25, 2020
Trying to use @ObservableObject and @EnvironmentObject, but changes in subviews don't propagate
View ContentView.swift
class Person: RawRepresentable, ObservableObject {
@Published var name: String
@Published var age: Int
// RawRepresentable
var rawValue: String {
get {
let value = "\(name):\(age)"
print("Returning raw value: "+value)
return value
cmsj / code.js
Last active Jul 12, 2018
Google Apps Script: given a regular email (e.g. backup results), archive old copies
View code.js
// Configuration data
// Each config should have the following keys:
// * age_min: maps to 'older_than:' in gmail query terms
// * age_max: maps to 'newer_than:' in gmail query terms
// * query: freeform gmail query terms to match against
// The age_min/age_max values don't need to exist, given the freeform query value,
// but age_min forces you to think about how frequent the emails are, and age_max
// forces you to not search for every single email tha matches the query
View zz-busybox-initramfs-fix
# This hook is for fixing busybox-initramfs issue while unlocking a luks
# encrypted rootfs. The problem is that the included busybox version
# is stripped down to the point that it breaks cryptroot-unlock script:
# This is a non-aggressive fix based on the original busybox-initramfs hook
# until the bug is fixed.
# busybox or busybox-static package must be present for this to work
View syslogreceiver.service
Description=Remote syslog to journald bridge
#!/usr/bin/env python3
""" - receive remote syslog events and pass them into
systemd's journal"""
import re
import socketserver
from systemd import journal
HOST, PORT = "", 514
View switch-power.diff
diff --git a/arch/arm64/boot/dts/nvidia/tegra210-nintendo-switch.dts b/arch/arm64/boot/dts/nvidia/tegra210-nintendo-switch.dts
index 814f414..e9c0a5f 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-nintendo-switch.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra210-nintendo-switch.dts
@@ -983,6 +983,14 @@
compatible = "gpio-keys";
label = "gpio-keys";
+ power {
+ label = "Power";
View gist:9841f36ec4d925ba42ef787ebec5de6c
diff --git a/usb_loader/switch.conf b/usb_loader/switch.conf
index f4555c3..39e1474 100644
--- a/usb_loader/switch.conf
+++ b/usb_loader/switch.conf
@@ -1,5 +1,3 @@
-../../linux/arch/arm64/boot/Image.gz:load 0x83000000
-../../linux/arch/arm64/boot/dts/nvidia/tegra210-nintendo-switch.dtb:load 0x8d000000
switch.scr.img:load 0x8e000000,jump_direct 0x8e000000
You can’t perform that action at this time.