Skip to content

Instantly share code, notes, and snippets.

View cconstable's full-sized avatar

Christopher Constable cconstable

View GitHub Profile
/*
* Hello Nicholas.
* Here are my thoughts on learning Flutter.
*
* Learning Dart and Flutter is going to be hard.
*
* We can't meaningfully learn by just consuming information. We must optimize for
* consuming the best information at the best time and in a format that we can
* absorb. In order to do this, we have to learn to ask good questions at
* appropriate times. In order to ask good questions, we need to be able to
@cconstable
cconstable / source.diff
Created March 19, 2020 17:33
Add file path to xcov output
diff --git a/lib/xcov/model/source.rb b/lib/xcov/model/source.rb
index 573db44..8ad3ff6 100644
--- a/lib/xcov/model/source.rb
+++ b/lib/xcov/model/source.rb
@@ -52,6 +52,7 @@ module Xcov
def json_value
value = {
"name" => @name,
+ "path" => @location,
"coverage" => @coverage,
#!/usr/bin/env node
// ---------------------------------------------------------------
// recursive fold implementations
// foldl implementation
function foldl(f, initial, list) {
if (list === undefined || list.length == 0) {
return initial
} else {
#import "AppDelegate.h"
#import <objc/runtime.h>
static NSString *Key = @"Key";
@interface Source : NSObject
@end
@implementation Source

Keynote I guess pushed an update that doesn't take hightlighted code from xCode anymore. So, I googled around and found highlight. It is a super useful utitlity to do syntax highlighting from the command line.

$ brew install highlight

If you are on Mavericks you may need to brew link lua to get it working right.

Hightlight has support for all kinds of languages and themes and it can wrap the code with line numbers, which is great.

@cconstable
cconstable / singleton.m
Created October 8, 2013 16:06
Generic Obj-C Singleton Code Snippet
+ (instancetype)sharedUtilities
{
__strong static id sharedUtilities;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedUtilities = [[self alloc] init];
});
return sharedUtilities;
}
@cconstable
cconstable / gist:5723099
Created June 6, 2013 17:02
UITapGestureRecognizer + blocks + UIView category = Add tap gestures with ease
// In UIVIew category...
#import <objc/runtime.h>
- (void)addTapGestureWithBlock:(void(^)())wasTappedBlock
{
static int selectorId = 0;
NSString *selectorName = [NSString stringWithFormat:@"tapGestureSelector%d:",selectorId];
IMP implementation = imp_implementationWithBlock(wasTappedBlock);
SEL newSelector = @selector(selectorName);
class_addMethod([self class], newSelector, implementation, "v@:@");
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:newSelector];
@cconstable
cconstable / UITextField+Tabbable.m
Created September 12, 2012 18:00
UITextField category that let's "next text fields" be assigned via interface builder.
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
/**
Adds a property called "nextTextField" to the UITextField class.
This property can be assigned in IB in a very natural way.
To make this work, something like this should be added to the VC
that is delegate of the UITextFields: