Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Currently Setting Status Message

Alf Watt alfwatt

💭
Currently Setting Status Message
View GitHub Profile
View Object Oriented Language Feature Names
Language | SmallTalk | Objective-C | C++ | Java | Python | Swift | Kotlin | UML
-|-|-|-|-|-|-|-|-
Object
Property
Method
Protocol
View color-switcher.md

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
View macOS 10.14 Semantic Colors
// 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 / scountf.c
Created Mar 29, 2018
scountf(char*) - counts the number of replacement strings in a format string, sorta
View scountf.c
static int
scountf(const char * format)
{
int count = 0;
int index = 0;
char this, next;
while ((this = format[index])) {
next = format[index++];
View NSRunLoop+Condition.h
#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 / create-elcap-install-iso.sh
Last active Jan 12, 2017
Create OS X Install ISO Scripts
View create-elcap-install-iso.sh
#!/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
View mach_gettime.c
#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 / ErrorReport.m
Last active Sep 22, 2015
+ (NSString*) errorReport:(NSError*) error
View ErrorReport.m
+ (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;
@alfwatt
alfwatt / ExceptionReport.m
Last active Jan 29, 2018
+ (NSString*) exceptionReport:(NSException*) exception
View ExceptionReport.m
#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;