Skip to content

Instantly share code, notes, and snippets.

View zorn's full-sized avatar
💸
Elixir Contractor For Hire

Mike Zornek zorn

💸
Elixir Contractor For Hire
View GitHub Profile
@zorn
zorn / gist:1172546
Created August 26, 2011 02:25
Things I wish the default Xcode unit testing did...
I wish code completion would work inside of STAssert*
I wish the console output would show number of asserts in addition to:
Executed 59 tests, with 0 failures (0 unexpected) in 0.999 (1.082) seconds
I wish the console would always be scrolled to the bottom and the current output (more of a general Xcode bug though).
I wish I didn't have to add a string to the end of every assert.
@zorn
zorn / gist:1181949
Created August 30, 2011 20:36
Trouble with nested content_tag in rails 3
In my app I made a helper method to help me render form rows and DRY up my code.
def form_row(form, input_type, symbol)
# Need to generate HTML like this
# <div class="clearfix">
# <%= f.label :first_name %>
# <div class="input">
# <%= f.text_field :first_name, html_options = {:class => 'xlarge'} %>
# </div>
# </div><!-- /clearfix -->
__block CompanyEditorWindowController *blockSelf = self;
self.kvoTokenForCompany = [self addKVOBlockForKeyPath:@"company" options:NSKeyValueObservingOptionNew handler:^(NSString *keyPath, id object, NSDictionary *change) {
[blockSelf updateUIBasedOnCompanyType];
}];
@zorn
zorn / gist:1256211
Created October 1, 2011 15:45
AppleScript can access the "formatted address" property of an address book card.
tell application "Address Book"
(* set thePerson to make new person with properties {first name:"Ben", last name:"Waldie", organization:"Automated Workflows, LLC", job title:"President"}
save *)
set thePeople to selection
repeat with thePerson in thePeople
set output to formatted address of address of thePerson
log "hello"
log output
end repeat
//
// ImageToDataTransformer.m
// ProfitTrain
//
// Created by Michael Zornek on 10/4/11.
// Copyright (c) 2011 Clickable Bliss. All rights reserved.
//
#import "ImageToDataTransformer.h"
@zorn
zorn / gist:1265078
Created October 5, 2011 17:24
Trying to turn [NSImage imageNamed:NSImageNameUser] into NSData
If I create an NSImage via something like:
NSImage *icon = [NSImage imageNamed:NSImageNameUser];
it only has one representation, a NSCoreUIImageRep which seems to be a private class.
I'd like to archive this image as an NSData but if I ask for the TIFFRepresentation I get a
small icon when the real NSImage I originally made seemed to be vector and would scale up to fill my image views.
I was kinda hoping images made this way would have a NSPDFImageRep I could use.
- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error {
NSNumberFormatter *formatter;
id object = nil;
formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setGeneratesDecimalNumbers:YES];
[formatter getObjectValue:&object forString:string errorDescription:error];
if (object) {
@zorn
zorn / gist:1279248
Created October 11, 2011 20:07
Core Data KVO / Undo issue
So I have this AddressBookCard entity. It has a BOOL attribute
called shouldSyncWithAddressBook. The idea being when set to YES
we will keep this AddressBookCard in sync with it's AddressBook
brother.
Part of the implementation for the AddressBookCard subclass of
NSManagedObject is some KVO for the shouldSyncWithAddressBook
attribute. When it is changed I check it's value and if YES I
instantly pull in the data from AddressBook.
@zorn
zorn / gist:1302408
Created October 20, 2011 21:14
There has got to be a clean way to do this...
<% if @event.main_venue.blank? %>
<div id="behavior_form_main_venue_form" class="behavior_form hide">
<% else %>
<div id="behavior_form_main_venue_form" class="behavior_form">
<% end %>
@zorn
zorn / gist:1359052
Created November 11, 2011 19:57
From iCloud Core Data sample code from Apple.
// From iCloud Core Data sample code from Apple.
// https://devforums.apple.com/thread/126670
- (void)dealloc {
[managedObjectContext__ release];
[managedObjectContext__ release];
[managedObjectContext__ release];
[recipeListController release];
[tabBarController release];