Skip to content

Instantly share code, notes, and snippets.

@JohnCoates
JohnCoates / Less Example.less
Last active October 17, 2015 23:52
CSSketch Examples
// Match based on class
.shadow {
@horizontal: 1px;
@vertical: 2px;
@blur: 15px;
@spread: 2px;
@color: rgba(0,0,0,0.4);
box-shadow: @horizontal @vertical @blur @spread @color;
}
@JohnCoates
JohnCoates / writeOutPasteboard.m
Created February 2, 2016 19:11
Mac OS X Pasteboard Viewer : NSPasteboard extract
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
NSLog(@"items: %@", pasteboard.pasteboardItems);
for (NSPasteboardItem *item in pasteboard.pasteboardItems) {
NSLog(@"types: %@", item.types);
for (NSString *type in item.types) {
@JohnCoates
JohnCoates / autotap.js
Created June 6, 2016 08:04
Auto-tap load more on YouTube
buttons = document.getElementsByTagName("button");
for (key in buttons) {
button = buttons[key];
attributes = button.attributes
if (attributes != undefined && attributes.getNamedItem('aria-label')) {
label = attributes.getNamedItem('aria-label')
value = String(label.value)
if (value == "Load more\n") {
console.log("clicking load more!");
button.click();
@JohnCoates
JohnCoates / Async.swift
Created September 16, 2015 04:23
Fixes issue in duemunk/Async by using an Objective-C helper class, adapted from sample code at https://forums.developer.apple.com/message/50963
//
// Async.swift
//
// Created by Tobias DM on 15/07/14.
//
// OS X 10.10+ and iOS 8.0+
// Only use with ARC
//
// The MIT License (MIT)
// Copyright (c) 2014 Tobias Due Munk
@JohnCoates
JohnCoates / FixUICodeCoverage
Created May 19, 2017 15:28
Fixes UI code coverage on builds run from xcode build
@import ObjectiveC.runtime;
@import MachO.dyld;
@import Foundation;
@interface IDELaunchParametersSnapshot : NSObject
+ (id)launchParametersWithSchemeIdentifier:(id)schemeIdentifier
launcherIdentifier:(id)launcherIdentifier
debuggerIdentifier:(id)debuggerIdentifier
launchStyle:(int)launchStyle
runnableLocation:(id)runnableLocation
@JohnCoates
JohnCoates / UITableView+Cells.swift
Created June 19, 2017 22:11
UITableView typed cells
extension UITableView {
func registerCell<CellType: UITableViewCell>(type: CellType.Type) {
register(type, forCellReuseIdentifier: String(describing: type))
}
func dequeueReusableCell<CellType: UITableViewCell>(for indexPath: IndexPath) -> CellType {
let identifier = String(describing: CellType.self)
let untypedCell = dequeueReusableCell(withIdentifier: identifier, for: indexPath)
@JohnCoates
JohnCoates / debugHook.py
Created August 21, 2017 03:44
Hook Python function calls for debugging
import subprocess
import os
def hook(hookfunc, oldfunc):
def foo(*args, **kwargs):
hookfunc(*args, **kwargs)
return oldfunc(*args, **kwargs)
return foo
def printFunction(*args, **kwargs):
@JohnCoates
JohnCoates / resetSimulators.rb
Created August 22, 2017 04:22
Keep only your favorite iOS simulators
# from https://gist.github.com/cabeca/cbaacbeb6a1cc4683aa5
#!/usr/bin/ruby
STDOUT.sync = true
device_types_output = `xcrun simctl list devicetypes`
device_types = device_types_output.scan /(.*) \((.*)\)/
runtimes_output = `xcrun simctl list runtimes`
runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/
@JohnCoates
JohnCoates / Future+NilMap.swift
Created March 10, 2019 23:54
Mapping on nil for Vapor 3
//
// Future+NilMap.swift
// Created on 3/10/19
//
import Async
public protocol OptionalConstrainable {
associatedtype Element
var asOptional: Optional<Element> { get }
@JohnCoates
JohnCoates / install-api.py
Created March 5, 2020 09:18 — forked from withzombies/install-api.py
Install the Binary Ninja Python API
#!/usr/bin/env python
import os
import sys
import os.path
import site
try:
import binaryninja
print "Binary Ninja API Installed"