Skip to content

Instantly share code, notes, and snippets.

@interface UIImage(ImmediateLoad)
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path;
@end
@implementation UIImage(ImmediateLoad)
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path {
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
@defunkt
defunkt / browser
Created March 1, 2010 10:01
pipe html to a browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo '<h1>hi mom!</h1>' | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then
@0xced
0xced / gist:372236
Created April 20, 2010 09:34
Automatically show keyboard in MFMailComposeViewController
@try
{
id textView = [mailComposeViewController valueForKeyPath:@"internal.mailComposeView.textView"];
if ([textView respondsToSelector:@selector(becomeFirstResponder)])
[textView becomeFirstResponder];
}
@catch (NSException *e) {}
@futureperfect
futureperfect / gist:1097449
Created July 21, 2011 15:35
Alan Kay's talk at Creative Think seminar, July 20, 1982
Alan Kay's talk at Creative Think seminar, July 20, 1982
Outline of talk: Metaphors, Magnetic Fields, Snobbery and Slogans
The best way to predict the future is to invent it.
Humans like fantasy and sharing:
Fantasy fulfills a need for a simpler, more controllable world.
Sharing is important - we're all communication junkies. We have an incredible bandwidth
@hatfinch
hatfinch / CGAffineTransformFromRectToRect.m
Created August 17, 2011 09:54
CGAffineTransformFromRectToRect (not working)
CGAffineTransform CGAffineTransformFromRectToRect(CGRect fromRect, CGRect toRect)
{
CGSize scale = CGSizeMake(toRect.size.width / fromRect.size.width, toRect.size.height / fromRect.size.height);
CGRect scaledFromRect = CGRectMake(fromRect.origin.x * scale.width, fromRect.origin.y * scale.height,
fromRect.size.width * scale.width, fromRect.size.height * scale.height);
CGSize translation = CGSizeMake(fromRect.origin.x - scaledFromRect.origin.x, fromRect.origin.y - scaledFromRect.origin.y);
return CGAffineTransformMake(scale.width, 0.0, 0.0, scale.height, translation.width, translation.height);
}
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@maebert
maebert / instagram_unshred.py
Last active September 28, 2023 14:41
Instagram Engineering Challenge in 20 lines of code
# Problem to be solved:
# https://instagram-engineering.com/instagram-engineering-challenge-the-unshredder-7ef3f7323ab1
import PIL.Image, numpy, fractions
image = numpy.asarray(PIL.Image.open('TokyoPanoramaShredded.png').convert('L'))
diff = numpy.diff([numpy.mean(column) for column in image.transpose()])
threshold, width = 1, 0
def sequence(conn, start):
seq = [start]
@ksm
ksm / UINavigationController+Fade.h
Created February 14, 2012 22:23
UINavigationController custom pop/push transition animation
/*
Copied and pasted from David Hamrick's blog:
Source: http://www.davidhamrick.com/2011/12/31/Changing-the-UINavigationController-animation-style.html
*/
@interface UINavigationController (Fade)
- (void)pushFadeViewController:(UIViewController *)viewController;
- (void)fadePopViewController;
@fjolnir
fjolnir / tlc.lua
Last active February 15, 2024 15:01
LuaJIT ObjC bridge
The bridge is now located at https://github.com/fjolnir/TLC
@jboner
jboner / latency.txt
Last active May 24, 2024 12:40
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD