Skip to content

Instantly share code, notes, and snippets.

View earltedly's full-sized avatar

Ted Bradley earltedly

View GitHub Profile
@tmcw
tmcw / disconnect.rb
Created July 22, 2011 04:06
bulk-export run data from Garmin Connect
#!/usr/bin/env ruby
## disconnect
# ./disconnect.rb -u yourusername
#
# This is a command-line utility for the bulk-downloading of run data from
# the connect.garmin.com web application, which has lackluster export
# capabilities.
#
@steipete
steipete / UIImage+PSPDFKitAdditions.m
Created August 13, 2011 20:52
Preload UIImage for super-smooth interaction. especially great if you use JPGs, which otherwise produce a noticeable lag on the main thread.
- (UIImage *)pspdf_preloadedImage {
CGImageRef image = self.CGImage;
// make a bitmap context of a suitable size to draw to, forcing decode
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
@cdown
cdown / gist:1163649
Last active April 9, 2024 01:10
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@gljeremy
gljeremy / disconnect.rb
Created September 21, 2011 14:03 — forked from tmcw/disconnect.rb
bulk-export run data from Garmin Connect
#!/usr/bin/env ruby
## disconnect
# ./disconnect.rb -u yourusername [-o /your/path] [-p yourhttpproxyserver]
#
# This is a command-line utility for the bulk-downloading of run data from
# the connect.garmin.com web application, which has lackluster export
# capabilities.
#
@benjie
benjie / HSBC.js
Created March 22, 2012 11:39
HSBC Personal Statement to CSV
/******************************
HSBC Personal Statement to CSV
v0.5
Copyright: Benjie Gillam (2012)
License: WTFPL v2.0 ( http://en.wikipedia.org/wiki/WTFPL )
Instructions:
Add the following bookmarklet to your browser:
@plexus
plexus / root_certificates.rb
Created May 11, 2012 13:29
Monkey patch Ruby 1.9 net/http to read system's root certificates
# Please fork if you can improve this. (e.g. Windows support)
#
# Ruby 1.9 doesn't contain any SSL root certificates, neither does it read the ones
# installed with your operating system. This results in an error like
#
# SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
#
# This solution is based on http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/
# but can be used to monkey patch 3rd party tools, e.g. Github's 'gist' command.
#
@earltedly
earltedly / garmin_tag.rb
Created July 9, 2012 08:37
Jekyll Garmin activity references
# Title: Simple Garmin tag for Jekyll
# Author: Ted Bradley http://monkeysandtea.com
# Description: easily embed a Garmin iframe using only the activity id. Has to be set to public though.
#
# Syntax {% garmin activityId [width height] %}
#
# Example:
# {% garmin 123456 465 548 %}
#
# Output:
@twobitlabs
twobitlabs / gist:4226365
Created December 6, 2012 17:35
Blocks cheat sheet
// http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html has a nice breakdown of the syntax--it helps to think of the ^ as similar to a pointer dereference symbol *
// block typedef:
typedef void(^Block)();
typedef void(^ConditionalBlock)(BOOL);
typedef NSString*(^BlockThatReturnsString)();
typedef NSString*(^ConditionalBlockThatReturnsString)(BOOL);
// block property with typedef:
@H2CO3
H2CO3 / main.m
Created August 3, 2013 22:14
Patch for https://github.com/xslim/mobileDeviceManager to support copying files *from* the device. Insert this at line 75 into Source/main.m.
} else if ([option isEqualToString:@"copyFrom"]) {
NSLog(@"Copying...");
AFCApplicationDirectory *appDir = [device newAFCApplicationDirectory:[arguments stringForKey:@"app"]];
AFCFileReference *infile = [appDir openForRead:[arguments stringForKey:@"from"]];
if (!infile) {
NSLog(@"Error: %@", [appDir lasterror]);
}
char buf[0x10000];
int outfile = open([arguments stringForKey:@"to"].UTF8String, O_CREAT | O_WRONLY, 0777);
@ericcj
ericcj / UIView+TLLayout.h
Created August 29, 2013 13:15
crazy that hiding a uiview doesn't affect its autolayout constraints. here's a category for the rest of the world who uses dynamic interfaces
#import <UIKit/UIKit.h>
@interface UIView (TLLayout)
@property (nonatomic, strong) NSArray *hiddenConstraints;
// set hidden and remove any constraints involving this view from its superview
- (void)hideAndRemoveConstraints;
- (void)showAndRestoreConstraints;