Skip to content

Instantly share code, notes, and snippets.

View alfwatt's full-sized avatar
💭
Currently Setting Status Message

Alf Watt alfwatt

💭
Currently Setting Status Message
View GitHub Profile
@alfwatt
alfwatt / ExceptionReport.m
Last active January 29, 2018 14:11
+ (NSString*) exceptionReport:(NSException*) exception
#import <execinfo.h>
#import <ExceptionHandling/ExceptionHandling.h>
+ (NSString*) exceptionReport:(NSException*) exception
{
NSMutableString* report = [NSMutableString new];
NSMutableArray *addresses = [NSMutableArray new];
NSString *stackTrace = [[exception userInfo] objectForKey:NSStackTraceKey];
NSScanner *scanner = [NSScanner scannerWithString:stackTrace];
NSString *token;
@alfwatt
alfwatt / ErrorReport.m
Last active September 22, 2015 02:32
+ (NSString*) errorReport:(NSError*) error
+ (NSString*) errorReport:(NSError*) error
{
NSMutableString* report = [NSMutableString new];
[report appendString:[NSString stringWithFormat:@"%@: %li\n\n%@", error.domain, error.code, error.userInfo]];
if( error = [[error userInfo] objectForKey:NSUnderlyingErrorKey] ) // we have to go deeper
{
[report appendString:[NSString stringWithFormat:@"\n\n- Underlying Error -\n\n"]];
[report appendString:[self errorReport:error]];
}
return report;
#include "mach_gettime.h"
#include <mach/mach_time.h>
#define MT_NANO (+1.0E-9)
#define MT_GIGA UINT64_C(1000000000)
// TODO create a list of timers,
static double mt_timebase = 0.0;
static uint64_t mt_timestart = 0;
@alfwatt
alfwatt / create-elcap-install-iso.sh
Last active January 12, 2017 20:51
Create OS X Install ISO Scripts
#!/bin/bash
OSX_NAME=ElCapitan
hdiutil attach "/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint /Volumes/esd
hdiutil create -o $OSX_NAME.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach $OSX_NAME.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/iso
asr restore -source /Volumes/esd/BaseSystem.dmg -target /Volumes/iso -noprompt -noverify -erase
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -rp /Volumes/esd/Packages /Volumes/OS\ X\ Base\ System/System/Installation
#import <Foundation/Foundation.h>
@interface NSRunLoop (Condition)
-(BOOL)runInDefaultModeWhileCondition:(BOOL *)condition inIntervals:(NSTimeInterval) quantum;
-(BOOL)runWhileCondition:(BOOL *)condition inMode:(NSString *)mode inIntervals:(NSTimeInterval) quantum;
@end
@alfwatt
alfwatt / scountf.c
Created March 29, 2018 19:18
scountf(char*) - counts the number of replacement strings in a format string, sorta
static int
scountf(const char * format)
{
int count = 0;
int index = 0;
char this, next;
while ((this = format[index])) {
next = format[index++];
// Dark Mode
#FFFEFE rgba(255, 254, 254, 0.847) hsla(320, 0%, 100%, 0.847) labelColor
#FFFEFE rgba(255, 254, 254, 0.549) hsla(320, 0%, 100%, 0.549) secondaryLabelColor
#FFFEFE rgba(255, 254, 254, 0.247) hsla(320, 0%, 100%, 0.247) tertiaryLabelColor
#FFFEFE rgba(255, 254, 254, 0.098) hsla(320, 0%, 100%, 0.098) quaternaryLabelColor
#3486FE rgba(52, 134, 254, 1.000) hsla(215, 79%, 99%, 1.000) linkColor
#FFFEFE rgba(255, 254, 254, 0.498) hsla(320, 0%, 100%, 0.498) placeholderTextColor
#FFFEFE rgba(255, 254, 254, 0.847) hsla(320, 0%, 100%, 0.847) windowFrameTextColor
#FFFEFE rgba(255, 254, 254, 1.000) hsla(320, 0%, 100%, 1.000) selectedMenuItemTextColor
@alfwatt
alfwatt / color-switcher.md
Last active February 21, 2019 22:29
Color Switcher

Color Switcher

Estimated time to complete 1-2 hours. The task is not timed and you can work at your own pace. You have at least 24 hours.

Tools

  • You can use any programming language you like
  • The project should open in Xcode or Android Studio and build and run on any iOS or Android device
  • Any 3rd party tooling (libraries and/or build systems) must be fully automated into the build