Skip to content

Instantly share code, notes, and snippets.

View nfarina's full-sized avatar

Nick Farina nfarina

View GitHub Profile
@nfarina
nfarina / Client.java
Created October 16, 2013 19:30
Code to reproduce an issue where Vert.x's `HttpClient.connectWebSocket()` hangs indefinitely and never calls the exception handler, if the connection is terminated during WebSocket connection negotiation.
HttpClient httpClient = vertx.createHttpClient();
httpClient.setHost("localhost");
httpClient.setPort(8888);
httpClient.setConnectTimeout(1000); // 1 second
httpClient.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable event) {
System.out.println("Failed!"); // never called
}
});
@nfarina
nfarina / UIView+FrameAdditions.h
Created August 21, 2012 06:40
UIView Frame helper getter/setter category methods
#import <UIKit/UIKit.h>
@interface UIView (SMFrameAdditions)
@property (nonatomic, assign) CGPoint $origin;
@property (nonatomic, assign) CGSize $size;
@property (nonatomic, assign) CGFloat $x, $y, $width, $height; // normal rect properties
@property (nonatomic, assign) CGFloat $left, $top, $right, $bottom; // these will stretch the rect
@end
@nfarina
nfarina / NSDate+Drawing.h
Created November 17, 2011 15:49
Useful functions for drawing NSDate in the exact style of Apple's iOS Mail app.
/*
The MIT License
Copyright (c) 2010 Nick Farina
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@nfarina
nfarina / base.js
Created January 5, 2011 21:36
A minimal jQuery-based JavaScript UI framework. In-progress and a bit raw.
(function(){ // begin private function
var copyProperties = function(props, o, overwrite, wrapFunctions) {
var wrap = wrapFunctions ? wrapFunctionWithSelf : nowrapFunction;
if (props) {
for (key in props) if (overwrite || o[key] === undefined) {
var getter = props.__lookupGetter__(key);
var setter = props.__lookupSetter__(key);
@nfarina
nfarina / UIWebView+HideShadows.h
Created July 7, 2010 15:18
Hide Shadows from UIWebView
// Removes those unsightly shadows from the top+bottom of your nice webview
@interface UIWebView (HideShadows)
- (void)hideShadows;
- (void)showShadows;
@end