Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Chris Jones cmsj

🏠
Working from home
View GitHub Profile
@cmsj
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 = GmailApp.search("from:(bugzilla@redhat.com) newer_than:1d");
GmailApp.createLabel('Bugzilla');
Logger.log("Got threads: " + threads.length);
for (var i = 0; i < threads.length; i++) {
processThread(threads[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
View appswitch.lua
lastApp = nil
function launchFocusOrSwitchBack(appName)
-- This function will launch appName if it's not running, focus
-- it if it is running, or if it's already focused, switch back
-- to whatever the last focused App was
-- (The Pro version of this would use hs.windowfilter to track
-- window focus events, but for now we'll just assume that this
-- is the only way apps will be switched)
local currentApp = hs.application.frontmostApplication()
@cmsj
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
cmsj / iOS-File-System-Extraction.md
Created Jul 31, 2017
Guide to extract the root file system and decompress the kernel cache for iOS.
View iOS-File-System-Extraction.md

iOS File System Extraction

For iOS 10 and Up

Starting with iOS 10.0 Apple decrypted the file system and kernel cache. All you have to do is download an IPSW, change the extension to .zip, and unarchive it. The largest size disk image inside the unarchived zip will be the root file system. Simply mount it to see its contents.

Links to download all iOS IPSWs.

For iOS 9 and Below

Originally from /u/RowRocka on Reddit. Gently edited for clarity.

Links to download all iOS OTA ZIPs.

View homegnu.sh
#!/bin/echo Don't execute this script directly, source it into your shell.
# This script will attempt to make your macOS system behave more like GNU for shell scripts
# by diverting as many commands as possible, to the GNU versions, provided by Homebrew
#
# For most Homebrew tools, their presence in /usr/local/bin and that being in your $PATH
# means you can use them as-is, but some tools appear with different names because macOS
# already has such a tool (e.g. find(1)). These tools generally also have a `gnubin` path
# which we can use to make them higher priority than the macOS equivalents.
#
# To use this:
View syslogreceiver.py
#!/usr/bin/env python3
"""syslogreceiver.py - receive remote syslog events and pass them into
systemd's journal"""
import re
import socketserver
from systemd import journal
HOST, PORT = "0.0.0.0", 514
@cmsj
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
#!/bin/sh
# 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:
# https://bugs.launchpad.net/ubuntu/+source/busybox/+bug/1651818
# 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
[Unit]
Description=Remote syslog to journald bridge
After=systemd-journald.service
[Service]
Type=simple
User=nobody
Group=nogroup
WorkingDirectory=/
ExecStart=/usr/local/bin/syslogreceiver.py
You can’t perform that action at this time.