Skip to content

Instantly share code, notes, and snippets.

View steipete's full-sized avatar

Peter Steinberger steipete

View GitHub Profile
@nathansmith
nathansmith / parseint.js
Created June 15, 2011 15:52
Makes parseInt default to radix of 10.
// Protect against parseInt being used
// without radix, by defaulting to 10.
// Conditionally check value, in case
// future implementations of parseInt
// provide native base-10 by default.
(function(window) {
var _parseInt = window.parseInt;
@MSch
MSch / LogHelper.h
Created July 3, 2011 23:17
The ultimate awesome logging method
#import <Cocoa/Cocoa.h>
#include <stdarg.h>
// by @MSch <[email protected]>
// From http://stackoverflow.com/questions/2632300/looping-through-macro-varargs-values
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
/* C99-style: anonymous argument referenced by __VA_ARGS__, empty arg not OK */
@AlanQuatermain
AlanQuatermain / gist:1063948
Created July 4, 2011 21:08
An example of how to use the prior gist
coverImage = [[KBImageCacheManager sharedManager] cachedImageForImageObject: imageObject type: imageType];
if ( coverImage == nil )
{
MAKE_WEAK_SELF();
_imageObserver = [[imageObject registerImageUpdateObserverUsingBlock: ^(UIImage *image, NSString *imageID, NSString *type) {
USE_WEAK_SELF();
self->_coverImageView.image = image;
[[KBImageCacheManager sharedManager] removeObserver: _imageObserver];
[_imageObserver release]; _imageObserver = nil;
}] retain];
@densa
densa / UIImage+FixOrient.m
Created July 5, 2011 10:56
UIImage fix orientation
- (UIImage *)fixOrientation {
// No-op if the orientation is already correct
if (self.imageOrientation == UIImageOrientationUp) return self;
// We need to calculate the proper transformation to make the image upright.
// We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
CGAffineTransform transform = CGAffineTransformIdentity;
switch (self.imageOrientation) {
@eaigner
eaigner / gist:1228804
Created September 20, 2011 10:22
Blocks as action target
// Assuming ARC is enabled.
// |button| is of type UIButton (works with NSButton as well).
[button addTarget:[^{ NSLog(@"Block invoked."); } copy]
action:@selector(invoke)
forControlEvents:UIControlEventTouchUpInside];
@chitchcock
chitchcock / 20111011_SteveYeggeGooglePlatformRant.md
Created October 12, 2011 15:53
Stevey's Google Platforms Rant

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

-(UIImage*)image:(UIImage*)image scaleAndRotateImageToMaxResolution:(int)resolution
{
int kMaxResolution = resolution; // Or whatever
CGImageRef imgRef = image.CGImage;
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);
@tonyarnold
tonyarnold / gist:1379451
Created November 19, 2011 22:21
Xcode build script to highlight TODO/FIXME/???/!!! in build logs, while excluding certain directories
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -path "${SRCROOT}/Vendor" -or -path "${SRCROOT}/.git" \) -prune -o \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
//
// MNDocumentConflictResolutionViewController.h
// MindNodeTouch
//
// Created by Markus Müller on 15.12.11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@class MNDocumentReference;
@evanlong
evanlong / LWHangDetector.h
Last active November 17, 2016 16:06
Simple Hang Detection
/**
Copyright (C) 2011 Evan Long
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 furnished to do
so, subject to the following conditions: