Skip to content

Instantly share code, notes, and snippets.

@mattyohe
mattyohe / gist:3943381
Created October 24, 2012 02:35
Bash file to grab info.plist
#! /bin/bash
ROOTOBJECT=`/usr/libexec/PlistBuddy -c "print rootObject" $1`
TARGET=`/usr/libexec/PlistBuddy -c "print objects:$ROOTOBJECT:targets:0" $1`
BLDCFGLIST=`/usr/libexec/PlistBuddy -c "print objects:$TARGET:buildConfigurationList" $1`
BLDCFGS=`/usr/libexec/PlistBuddy -c "print objects:$BLDCFGLIST:buildConfigurations:0" $1`
INFO=`/usr/libexec/PlistBuddy -c "print objects:$BLDCFGS:buildSettings:INFOPLIST_FILE" $1`
echo $INFO
@mattyohe
mattyohe / gist:3948987
Created October 24, 2012 21:24
Letterpress 1.0 dictionary
This file has been truncated, but you can view the full file.
aa
aah
aahed
aahing
aahs
aal
aalii
aaliis
aals
aardvark
@mattyohe
mattyohe / gist:4456183
Created January 4, 2013 21:24
semaphore example
dispatch_queue_t queue = dispatch_queue_create("My Queue", DISPATCH_QUEUE_SERIAL);
__block dispatch_semaphore_t waiter = dispatch_semaphore_create(0);
dispatch_async(queue, ^{
NSLog(@"Before Sleep");
sleep(2);
NSLog(@"After Sleep");
dispatch_semaphore_signal(waiter);
From: http://snipt.net/yonishin/about-xcode-4-project-template
XCode 4 Projects and Files Template Folder: /Developer/Library/Xcode/Templates
Examples:
/Developer/Library/Xcode/Templates/Project Templates/Base/Other/Empty.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Base/Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Mac Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Cocoa Application.xctemplate
@mattyohe
mattyohe / UIView+NibLoading.h
Last active December 12, 2015 10:19
UIView Nib loading.
//
// UIView+NibLoading.h
//
// Created by Matt Yohe on 2/11/13.
//
#import <UIKit/UIKit.h>
@interface UIView (NibLoading)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void) methodUsingDeprecatedStuff {
//use deprecated stuff
}
#pragma clang diagnostic pop
Condition types: http://w1.weather.gov/xml/current_obs/weather.php
return @{
@"bkn" : @"H",
@"skc" : @"B",
@"few" : @"N",
@"sct" : @"H",
@"ovc" : @"L",
@"fg" : @"M",
@"smoke" : @"N",
//
// main.c
// CopyList
//
// Created by Joshua Weinberg on 3/25/13.
// Copyright (c) 2013 Joshua Weinberg. All rights reserved.
//
#include <iostream>
#include <map>
@mattyohe
mattyohe / gist:5292264
Last active December 15, 2015 16:49
Scrollview inset adjusting
-(void)keyboardDidAppearNotification:(NSNotification *)note
{
// Grab the height of the keyboard, set an inset
NSDictionary* info = [note userInfo];
CGRect kbFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect convertedFromView = [[self scrollView] convertRect:kbFrame fromView:nil];
CGFloat miny = CGRectGetMinY(convertedFromView);
CGFloat height = CGRectGetHeight(self.scrollView.frame) - miny + [[self tableView] contentOffset].y;
[[self scrollView] setContentInset:UIEdgeInsetsMake(0, 0, height, 0)];
@mattyohe
mattyohe / gist:5294291
Created April 2, 2013 17:32
Date Formatting Template
NSString *dateString = @"Fri, 08 Mar 2013 21:38:49 EST";
NSString *dateTemplate = @"EEE, dd MMM yyyy HH:mm:ss zzz";
NSDateFormatter *incommingFormatter = [[NSDateFormatter alloc] init];
[incommingFormatter setDateFormat:dateTemplate];
NSDate *date = [incommingFormatter dateFromString:dateString];
NSLog(@"%@",date);