Skip to content

Instantly share code, notes, and snippets.

View drunknbass's full-sized avatar
🏠
Working from home

Aaron Alexander drunknbass

🏠
Working from home
View GitHub Profile
- (NSArray *) runningProcesses {
//CTL_KERN,KERN_PROC,KERN_PROC_ALL
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL ,0};
size_t miblen = 4;
size_t size;
int st = sysctl(mib, miblen, NULL, &size, NULL, 0);
struct kinfo_proc * process = NULL;
struct kinfo_proc * newprocess = NULL;
@drunknbass
drunknbass / gist:3074015
Created July 9, 2012 03:08
Swizzletastic
#include <objc/runtime.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "SwizzleMyNizzleProtocol.h"
void SwizzleMethod(Class _class, SEL sel, IMP imp, const char *prefix) {
if (_class == nil)
/System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
extern uint32_t dyld_get_program_sdk_version() WEAK_IMPORT_ATTRIBUTE;
extern BOOL DZApplicationUsesLegacyUI(void)
{
static dispatch_once_t onceToken;
static BOOL legacyUI = NO;
dispatch_once(&onceToken, ^{
uint32_t sdk = __IPHONE_OS_VERSION_MIN_REQUIRED;
if (dyld_get_program_sdk_version != NULL) {
sdk = dyld_get_program_sdk_version();
// The purpose of this gist is to provide examples of many real life date computations
// This is uploaded as a gist so that it can be copy and pasted into either a OS X or
// iOS project. You can either take it all "[Cmd]+[A], [Cmd]+[C]" or just a small piece.
// The results are fairly well formattes as log output and I recommend that you run this
// code to see the actual results yourself. Change some of the values and see what happens.
#pragma mark - Setup
NSString *line = @"–––––––––––––––––––––––––––––––––––––––––––––––––––––––";
@drunknbass
drunknbass / gist:7775421
Created December 3, 2013 19:02
Pass list to Xcode via command line build (IPA)
# Usage:
# cd to dir with xcode.pbxproj and execute.
ARCHIVE_PATH='output.ipa'
BAR='\"B:A:R\"'
xcodebuild -scheme "My Scheme" -configuration "Enterprise" GCC_PREPROCESSOR_DEFINITIONS='FOO='$BAR'' archive -archivePath $ARCHIVE_PATH || { echo Enterprise BUILD failed"; exit 1; }
@drunknbass
drunknbass / Foundation.py
Created January 13, 2016 00:57 — forked from steventroughtonsmith/Foundation.py
UIKit+UIFoundation & Foundation for Pythonista - autoconverted from SDK tbd (includes non-public SPI)
# coding: utf-8
from objc_util import *
NSAKDeserializer = ObjCClass('NSAKDeserializer')
NSAKDeserializerStream = ObjCClass('NSAKDeserializerStream')
NSAKSerializer = ObjCClass('NSAKSerializer')
NSAKSerializerStream = ObjCClass('NSAKSerializerStream')
NSAbstractLayoutGuide = ObjCClass('NSAbstractLayoutGuide')
NSAddressCheckingResult = ObjCClass('NSAddressCheckingResult')
NSAffineTransform = ObjCClass('NSAffineTransform')
@drunknbass
drunknbass / gist:6bba2c6b787c2426432342b54cbb8ed2
Created September 20, 2017 06:13
iOS Simulator Video Utils
brew install gifsicle
brew install xquartz
brew install ffmpeg
gifType=".gif"
movType=".m4v"
timestring=`date +"%m_%d_%Y"`
capturePath=~/Desktop/ScreenRecording_$timestring
displayDialog () {
@drunknbass
drunknbass / EnvConfig.swift
Created June 17, 2016 04:05
Firebase stage + Prod config
import Foundation
@objc(EnvConfig)
class EnvConfig: NSObject {
#if ENVConfigStaging
class var isProduction:Bool {
return false
}
@drunknbass
drunknbass / toggledarkmode.command
Last active March 25, 2020 23:33
Toggle dark mode on currently running simulator
#! /bin/sh
booted_uuids=`xcrun simctl list devices | \
grep "(Booted)" | \
grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})"`
all_uuids=($(echo $booted_uuids | tr ";" "\n"))
last_uuid=${all_uuids[${#all_uuids[@]}-1]}
exit_cleanly() {