Skip to content

Instantly share code, notes, and snippets.

View tettoffensive's full-sized avatar

Stuart Tett tettoffensive

View GitHub Profile
@tettoffensive
tettoffensive / devtools.css
Created June 14, 2023 17:20
Custom Dev Tools CSS
.platform-mac, :host-context(.platform-mac) {
--monospace-font-size: 1rem;
--monospace-font-family: 'Berkeley Mono','JetBrains Mono',Menlo, Monaco, 'Courier New', monospace;
--source-code-font-size: 1rem;
--source-code-font-family: 'Berkeley Mono','JetBrains Mono',Menlo, Monaco, 'Courier New', monospace;
}
.platform-mac, .platform-mac .source-code {
font-family: var(--monospace-font-family);
}
@tettoffensive
tettoffensive / calendar.json
Last active October 15, 2022 20:29
JSON files
{
"items": [
{
"month": "October",
"days_of_week": ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],
"day_start": 7,
"date_items": [
{
"dd": 1,
"available_times": []
@tettoffensive
tettoffensive / index.ts
Created December 29, 2020 19:58
Import all Firebase Functions.
import { sync } from 'glob';
import { camelCase, last } from 'lodash';
const files = sync('./**/*.function.[tj]s', { cwd: __dirname, ignore: './node_modules/**' });
for (let f = 0, fl = files.length; f < fl; f += 1) {
const file = files[f];
const functionName = camelCase(last(file.slice(0, -12).split('/'))); // Strip off '.function.js'
if (!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME === functionName) {
// eslint-disable-next-line import/no-dynamic-require, global-require
exports[functionName] = require(file);
@tettoffensive
tettoffensive / copyFirestoreDB.js
Last active August 12, 2019 18:03 — forked from brunobraga95/copyFirestoreDB.js
Copy firestore database
const firebase = require('firebase-admin');
var serviceAccountSource = require("./source.json"); // source DB key
var serviceAccountDestination = require("./destination.json"); // destination DB key
const sourceAdmin = firebase.initializeApp({
credential: firebase.credential.cert(serviceAccountSource)
});
const destinationAdmin = firebase.initializeApp({

Ingredients

  1. 1 Egg
  2. Salt
  3. Butter, Duck Fat

Steps

  1. Heat your skillet on medium for a few minutes
  2. Add your fat. If the fat is smoking, pull back on the heat
  3. Crack the egg into the pan
  4. Sprinkle salt on the egg
@tettoffensive
tettoffensive / UIAlertAction+Swizzle.swift
Created April 7, 2017 23:29
How to Swizzle what looks like an init method in Swift that's really a class method in Obj-C
typealias UIAlertActionHandler = ((UIAlertAction) -> Swift.Void)?
private struct AssociatedKeys {
static var handler = "cc_handler"
}
private let swizzling: (UIAlertAction.Type) -> () = { action in
// in swift this looks like an init, but in obj-c it's really actionWithTitle:style:handler class method
let originalSelector = #selector(UIAlertAction.init(title:style:handler:))
let swizzledSelector = #selector(UIAlertAction.action(testTitle:style:handler:)) // so swizzling an init won't work. we have to use another class method
@tettoffensive
tettoffensive / # infer - 2016-11-07_17-21-10.txt
Created November 8, 2016 01:26
infer on macOS 10.12 - Homebrew build logs
Homebrew build logs for infer on macOS 10.12
Build date: 2016-11-07 17:21:10
@tettoffensive
tettoffensive / GHRunLoopWatchdog.h
Created October 7, 2016 22:34 — forked from jspahrsummers/GHRunLoopWatchdog.h
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@tettoffensive
tettoffensive / iOSVersionCheck.h
Created September 8, 2016 19:30 — forked from krin-san/iOSVersionCheck.h
NSProcessInfo-based iOS version check macro (iOS 8+)
#define INC_SYSTEM_VERSION(v) ((NSOperatingSystemVersion){v.majorVersion, v.minorVersion + 1, 0})
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:v]
#define SYSTEM_VERSION_LESS_THAN(v) (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v))
#define SYSTEM_VERSION_EQUAL_TO(v) (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) && (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(INC_SYSTEM_VERSION(v))))
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) (SYSTEM_VERSION_LESS_THAN(v) || SYSTEM_VERSION_EQUAL_TO(v))
#define SYSTEM_VERSION_GREATER_THAN(v) (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) && (!SYSTEM_VERSION_EQUAL_TO(v)))
/*
// Manual logical check
NSOperatingSystemVersion v = (NSOperatingSystemVersion){8, 4, 0};