Skip to content

Instantly share code, notes, and snippets.

View hborders's full-sized avatar

Heath Borders hborders

View GitHub Profile
@hborders
hborders / google-io-todo
Created March 22, 2014 19:55
A list of Google IO videos I need to watch.
https://developers.google.com/events/io/sessions/326148829
https://developers.google.com/events/io/2012/sessions/gooio2012/106/
https://developers.google.com/events/io/2012/sessions/gooio2012/131/
https://developers.google.com/events/io/2012/sessions/gooio2012/114/
https://developers.google.com/events/io/2012/sessions/gooio2012/122/
https://developers.google.com/events/io/2012/sessions/gooio2012/103/
https://developers.google.com/events/io/2012/sessions/gooio2012/107/
https://developers.google.com/events/io/2012/sessions/gooio2012/102/
https://developers.google.com/events/io/sessions/326425499
https://sites.google.com/site/io/dalvik-vm-internals
#!/bin/bash
# Argument = -h -v -i groupId:artifactId:version -c classifier -p packaging -r repository
#shopt -o -s xtrace
# Define Nexus Configuration
NEXUS_BASE=http://repository.example.com:8081/nexus
REST_PATH=/service/local
ART_REDIR=/artifact/maven/redirect
@hborders
hborders / Better way to return failure?
Created February 20, 2015 15:09
Is there a better way to handle the failure case?
class Box<A> {
public let value: A
init(_ value: A) { self.value = value }
}
enum Result<A> {
case Success(Box<A>)
case Failure(NSError)
}
private class Poller<ResultType, ErrorType: JiveError, ErrorCodeType where ErrorType.CodeType == ErrorCodeType> {
private let retryInterval: NSTimeInterval
private let timeoutErrorCode: ErrorCodeType
private let expectation: XCTestExpectation
private var state: PollerState<ResultType, ErrorType>
init(
createJiveFuture: () -> JiveFuture<ResultType, ErrorType>,
acceptJiveResult: (JiveResult<ResultType, ErrorType>) -> JiveResult<ResultType, ErrorType>?,
retryInterval: NSTimeInterval,
@hborders
hborders / gist:316123ce2e506b9f11bc
Last active August 29, 2015 14:21
Swift enums with labels
enum Foo {
// enums can have many values, and they can be labeled
case Bar(
barString: String,
barInt: Int)
// or unlabeled
case Baz(
String,
Int)
}
:start
duplicate
not
goto done
push 1
add
duplicate
push 2
subtract
push 3 -1
@hborders
hborders / gist:4064006
Created November 13, 2012 05:04
Example of my use of UIViewController containment lifecycle methods inside a custom tab bar controller.
- (void) setSelectedViewController:(UIViewController<SFCustomTabbedViewController> *)selectedViewController {
if (_selectedViewController != selectedViewController) {
if (_selectedViewController) {
NSUInteger selectedViewControllerIndex = [self.viewControllers indexOfObject:_selectedViewController];
if (selectedViewControllerIndex != NSNotFound) {
UIButton *tabButton = [self.tabButtons objectAtIndex:selectedViewControllerIndex];
tabButton.selected = NO;
}
[_selectedViewController willMoveToParentViewController:nil];
@hborders
hborders / gist:5790844
Created June 16, 2013 05:08
A good comment
// if we submit more than one div with a class of "jive-rendered-context", only the first div is accepted
innerHTMLContent = innerHTMLContent.replace(/(<div class="jive-rendered-content">)/ig,"<div>");
@hborders
hborders / gist:5790859
Created June 16, 2013 05:19
Another "why" comment that is valuable. Without the comment, a naive developer might very declare the values at the call site, breaking the SWT library.
public static final int BUTTON_MASK;
public static final int MODIFIER_MASK;
static {
/*
* These values represent bit masks that may need to
* expand in the future. Therefore they are not initialized
* in the declaration to stop the compiler from inlining.
*/
BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3 | BUTTON4 | BUTTON5;
@hborders
hborders / gist:5790870
Created June 16, 2013 05:25
From the SWT source. This just shows why some wacky API exists. I'm not sure this is the best solution for the problem, but the code definitely doesn't stand on its own. You could probably back it with a unit test, but I'd hate to have to delete these seemingly useless lines and run a testsuite just to find out what this did.
/*
* Plug-ins need an opportunity to set the org.eclipse.swt.browser.DefaultType
* system property before the first Browser is created. To facilitate this,
* reflection is used to reference non-existent class
* org.eclipse.swt.browser.BrowserInitializer the first time a Browser is created.
* A client wishing to use this hook can do so by creating a fragment of
* org.eclipse.swt that implements this class and sets the system property in its
* static initializer.
*/
try {