Skip to content

Instantly share code, notes, and snippets.

View tettoffensive's full-sized avatar

Stuart Tett tettoffensive

View GitHub Profile
@tettoffensive
tettoffensive / IOMobileFramebuffer.h
Created December 11, 2015 21:46 — forked from anthonya1999/IOMobileFramebuffer.h
A recent disassembly of IOMobileFramebuffer framework
/* You may have to include your IOSurface header to compile, because of the GetLayerDefaultSurface function. If you do not have it, you may just uncomment the typedef to an IOSurface below. */
#include <stdio.h>
#include <sys/mman.h>
#ifdef __cplusplus
extern "C" {
#endif
#define kIOMobileFramebufferError 0xE0000000
@tettoffensive
tettoffensive / Anchor.swift
Created February 23, 2016 00:31
NSLayoutAnchor for 10.10/iOS8
//
// Anchor.swift
// AnchorTest
//
// Created by Jonathan Wight on 7/10/15.
// Copyright © 2015 schwa.io. All rights reserved.
//
#if os(OSX)
import AppKit
@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};

1. Clone your fork:

git clone [email protected]: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 / 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
@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 / 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

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 / 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({
@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);