Skip to content

Instantly share code, notes, and snippets.

@wohckcin
wohckcin / mountain-lion-brew-setup.markdown
Created July 29, 2012 15:11 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from http://developer.apple.com. You will not be able to submit apps to any stores using this XCode version, so turn away if that is something you might want to do.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

@iamjpg
iamjpg / gist:3194394
Created July 28, 2012 18:48
The Iron by Henry Rollins
This article originally appeared in Details Magazine some time around 1994 or 1995, I believe. This is a great essay by Henry Rollins on the benefits and lessons of lifting weights.
=================================================
I believe that the definition of definition is reinvention. To not be like your parents. To not be like your friends. To be yourself.
Completely.
When I was young I had no sense of myself. All I was, was a product of all the fear and humiliation I suffered. Fear of my parents. The humiliation of teachers calling me "garbage can" and telling me I'd be mowing lawns for a living. And the very real terror of my fellow students. I was threatened and beaten up for the color of my skin and my size. I was skinny and clumsy, and when others would tease me I didn't run home crying, wondering why.
@sspencer
sspencer / FormatThousandsSeparator.m
Created July 27, 2012 19:18
Format Decimal Number with Thousands Separator
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSLog(@"formatted: %@", [formatter stringFromNumber:[NSNumber numberWithInt:1234567]]);
@tburch
tburch / FizzBuzz.scala
Created July 27, 2012 16:31
FizzBuzz
(1 to 100) map { x =>
(x % 3, x % 5) match {
case (0, 0) => ”FizzBuzz”
case (0, _) => “Fizz”
case (_, 0) => “Buzz”
case _ => x.toString
}
} foreach println
/*
* Finder.h
*/
#import <AppKit/AppKit.h>
#import <ScriptingBridge/ScriptingBridge.h>
@class FinderApplication, FinderItem, FinderContainer, FinderComputerObject, FinderDisk, FinderFolder, FinderDesktopObject, FinderTrashObject, FinderFile, FinderAliasFile, FinderApplicationFile, FinderDocumentFile, FinderInternetLocationFile, FinderClipping, FinderPackage, FinderWindow, FinderFinderWindow, FinderDesktopWindow, FinderInformationWindow, FinderPreferencesWindow, FinderClippingWindow, FinderProcess, FinderApplicationProcess, FinderDeskAccessoryProcess, FinderPreferences, FinderLabel, FinderIconFamily, FinderIconViewOptions, FinderColumnViewOptions, FinderListViewOptions, FinderColumn, FinderAliasList;
@ipodishima
ipodishima / gist:3188708
Created July 27, 2012 15:34
Remove Shadow on web view
// From http://stackoverflow.com/questions/1074320/remove-uiwebview-shadow
- (void) removeShadowForWebView:(UIWebView*)webV
{
// remove the shadow
if ([[webV subviews] count] > 0)
{
for (UIView* shadowView in [[[webV subviews] objectAtIndex:0] subviews])
{
if ([shadowView isKindOfClass:[UIImageView class]]) {
[shadowView setHidden:YES];
@naiveal
naiveal / gist:3187150
Created July 27, 2012 09:48
printfTreeLevelOfView
void printfTreeLevelOfView(UIView *view, int maxLevel)
{
UIView *tempView;
NSArray *subViews = [view subviews];
static int level = 0;
level++;
for(tempView in subViews)
{
if ( level <= maxLevel) {
for (int i = 0; i < level; i++)
@flandy84
flandy84 / gist:3183844
Created July 26, 2012 19:05
"modern Objective-C" syntax
//"modern Objective-C" syntax
//new enum-macros for better autocompletion, switch statement, more precise warnings, ...
typedef NS_ENUM(NSInteger, MyViewContentMode) {
MyViewContentModeLeft,
MyViewContentModeRight,
MyViewContentModeTopLeft,
MyViewContentModeTopRight,
- (void)_updateResults:(void (^)(void))block caller:(dispatch_queue_t)callerqueue
{
__unsafe_unretained NUData* wself = self;
dispatch_sync(_serial_results_queue, ^{
NSManagedObjectContext* ctx = updateContext;
__block NSArray* results = nil;
[ctx performBlockAndWait:^{
@tsbob
tsbob / gist:3181214
Created July 26, 2012 09:31
优化字符串定义的宏
#define OC(str) [NSString stringWithCString:(str) encoding:NSUTF8StringEncoding]
#ifdef DEBUG
# define LOG(fmt, ...) do { \
NSString* file = [[NSString alloc] initWithFormat:@"%s", __FILE__]; \
NSLog((@"%@(%d) " fmt), [file lastPathComponent], __LINE__, ##__VA_ARGS__); \
[file release]; \
} while(0)
# define LOG_METHOD NSLog(@"%s", __func__)
# define LOG_CMETHOD NSLog(@"%@/%@", NSStringFromClass([self class]), NSStringFromSelector(_cmd))