Skip to content

Instantly share code, notes, and snippets.

View phildow's full-sized avatar

Philip Dow phildow

View GitHub Profile
[alias]
a = add
b = branch
c = commit
d = diff
f = fetch
g = grep
l = log
m = merge
o = checkout
@phildow
phildow / session_config.py
Last active January 21, 2020 20:03
Prevent CUDA initialization failures in tensorflow with gpu_options.allow_growth=True
# Using tf.estimator without keras
session_config = tf.ConfigProto()
session_config.gpu_options.allow_growth=True
run_config = tf.estimator.RunConfig(session_config=session_config)
classifier = tf.estimator.Estimator(model_fn=..., config=run_config)
# Using any keras
session_config = tf.ConfigProto()
#import <UIKit/UIKit.h>
@interface UIImage (SDWebImageAnimatedGifSwizzle)
@end
@phildow
phildow / CLLocation+EXIFGPS.h
Last active December 2, 2019 02:37
Category to create GPS metadata dictionary from CLLocation and CLHeading for writing to EXIF data in images.
#import <CoreLocation/CoreLocation.h>
#import <ImageIO/ImageIO.h>
@interface CLLocation (EXIFGPS)
- (NSDictionary*) EXIFMetadataWithHeading:(CLHeading*)heading;
@end
@interface NSDate (EXIFGPS)
@phildow
phildow / gist:5118857
Last active December 14, 2015 16:59
Initializing an NSArray with a block that is called for each element, allowing the array elements to initialize themselves as the array is built.
// NSArray+BlocksInit.h
- (id) initWithCount:(NSUInteger)count block:(id(^)(NSUInteger index))block
{
NSMutableArray *array = [[NSMutableArray alloc] init];
for ( NSUInteger i = 0; i < count; i++ ) {
id element = block(i);
if (element) [array addObject:element];
}
return [array copy];
@phildow
phildow / map.rb
Created February 7, 2013 23:27
Implement map in ruby using a recursive function that takes a block
#!/usr/bin/env ruby -w
def map(l,&f)
return [] if l.empty?
return [ f.call(l.first) ].concat map(l.slice(1..l.length), &f)
end
puts map [1,2,3,4] {|x| x+1}
puts map ['a','b','c','d'] {|x| "#{x} is a letter"}