<?xml version='1.0' encoding='utf-8'?>

<rss version='2.0'
  xmlns:content='http://purl.org/rss/1.0/modules/content/'
  xmlns:dc='http://purl.org/dc/elements/1.1/'
>

<!--
<rdf:RDF
  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
  xmlns='http://purl.org/rss/1.0/'
>
-->

<channel>

  <title>Borkware Quickies</title>
  <description>
    Quickies - Little chunklets of Mac OS X and Unix Information.
  </description>
  <pubDate>Tue, 29 Dec 2009 21:38:27 UTC</pubDate>
  <link>http://borkware.com</link>

<item>
  <title>Binding an NSPopupButton (General-&gt;General)</title>
  <pubDate>Tue, 29 Dec 2009 21:38:27 UTC</pubDate>
  <description>
     To bind an NSPopupButton:&lt;br&gt;&lt;br&gt;
&lt;ul&gt;
  &lt;li&gt; Have an NSArray somewhere that you want to supply the popup
  &lt;li&gt; Make an NSArrayController in the nib file (say call it &#34;greeble&#34;), and binds its Value to some keypath (such as your AppDelegate.greebleArray ivar)
  &lt;li&gt; Bind the popup&#39;s &lt;b&gt;Content&lt;/b&gt; to the array controller&#39;s arranged objects (greeble.arrangedObjects). These are the objects that are behind the popup.
  &lt;li&gt; Bind the popup&#39;s &lt;b&gt;Content Values&lt;/b&gt; to a key path that includes a displayable string.  Assuming the objets in the greebleArray array have a title property, you&#39;d bind it to greeble.arrangedObjects.title
  &lt;li&gt; Bind the popup&#39;s &lt;b&gt;Selected Object&lt;/b&gt; to something, such as an ivar of the type of object that&#39;s in the greebleArray.  If said ivar is called selectedGreeble, you&#39;d bind to AppDelegate&#39;s selectedGreeble.
 
&lt;/ul&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=405</guid>
</item>

<item>
  <title>Continuous Text Field (General-&gt;General)</title>
  <pubDate>Tue, 29 Dec 2009 15:54:36 UTC</pubDate>
  <description>
     Courtesy of Jens Bauer.  Sometimes you&#39;d like a text field to notify on every text change.&lt;br&gt;&lt;br&gt;
&lt;pre&gt;@interface FSContinousTextField : NSTextField
@end

@implementation FSContinousTextField

- (void) textDidChange: (NSNotification *) aNotification {
	[[self target] performSelector:[self action] withObject:self];
}

@end&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=404</guid>
</item>

<item>
  <title>Hiding TOC bar in xcode permanently (Xcode-&gt;General)</title>
  <pubDate>Tue, 29 Dec 2009 14:07:53 UTC</pubDate>
  <description>
     Thanks to Jens Bauer who sent this my way.&lt;br&gt;&lt;br&gt;
&#34;When I option-double-click an object in my source-code, I got a surprise with newer Xcodes. There&#39;s a huge TOC bar in the left side, forcing me to have a large window, that overlaps my source-code, so I can&#39;t look at the documentation and type at the same time. Furthermore it makes the sentences very &#39;tall&#39;, which I can&#39;t get used to.  So I dropped my coding, went for a hunt. I wanted to go and get rid of that annoying demon. I found it and cast it out (By hand!)&#34;

&lt;p&gt;

Here&#39;s how Jens cast out that demon.  It&#39;s two different edits:

&lt;p&gt;

To make the TOC section (left side bar) of the developer documentation default to be hidden, do as follows:

&lt;p&gt;
Before you begin, make the two files and their parent-folders writable.
&lt;p&gt;
In the file....
&lt;p&gt;
&lt;code&gt;/Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Resources/CSS/frameset_styles.css&lt;/code&gt;
&lt;p&gt;
...change the line...
&lt;p&gt;
&lt;code&gt;#bodyText { margin-left: 210px; }&lt;/code&gt;
&lt;p&gt;
...to read...
&lt;p&gt;
&lt;code&gt;#bodyText { /* margin-left: 210px; */ margin-left:10px; /* TOC-FIX */ }&lt;/code&gt;
&lt;p&gt;
...And in the file...
&lt;p&gt;
&lt;p&gt;/Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Resources/JavaScript/page.js&lt;/p&gt;
&lt;p&gt;
...add the following somewhere in initialize_page() function, for instance at the bottom, right before the closing brace...
&lt;p&gt;
&lt;code&gt;    showHideTOC(&#39;hide&#39;);		// TOC-FIX&lt;/code&gt;
&lt;p&gt;
...now you have a much better view!!

&lt;p&gt;
Note that you&#39;ll need to apply this patch when the docs get upgraded.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=403</guid>
</item>

<item>
  <title>Converting xsd:date to NSDate (NSDate-&gt;General)</title>
  <pubDate>Fri, 25 Dec 2009 20:10:40 UTC</pubDate>
  <description>
     &lt;code&gt;xsd:date&lt;/code&gt; has a format that&#39;s a subset of the full ISO8601 format.  Here&#39;s a quick way to convert an &lt;code&gt;xsd:date&lt;/code&gt; to an NSDate.  Based on a forum posting by Jens Alfke.  For a full ISO 8601 parser, check out &lt;a href=&#34;http://boredzo.org/iso8601parser/&#34;&gt;the one&lt;/a&gt; by Peter Hosey.&lt;br&gt;&lt;br&gt;
&lt;p&gt;

Note that thiscode 

&lt;pre&gt;
NSDate *xsdDateTimeToNSDate (NSString *dateTime) {
    static NSDateFormatter *xsdDateTimeFormatter;
    if (!xsdDateTimeFormatter) {
        xsdDateTimeFormatter = [[NSDateFormatter alloc] init];  // Keep around forever
        xsdDateTimeFormatter.timeStyle = NSDateFormatterFullStyle;
        xsdDateTimeFormatter.dateFormat = @&#34;yyyy-MM-dd&#39;T&#39;HH:mm:sszzz&#34;;
    }

    // Date formatters don&#39;t grok a single trailing Z, so make it &#34;GMT&#34;.
    if ([dateTime hasSuffix: @&#34;Z&#34;]) {
        dateTime = [[dateTime substringToIndex: dateTime.length - 1]
                       stringByAppendingString: @&#34;GMT&#34;];
    }

    NSDate *date = [xsdDateTimeFormatter dateFromString: dateTime];
    if (!date) NSLog(@&#34;could not parse date &#39;%@&#39;&#34;, dateTime);

    return (date);

} // xsdDateTimeToNSDate
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=402</guid>
</item>

<item>
  <title>Supplying bitbucket username / password (Mercurial-&gt;General)</title>
  <pubDate>Fri, 25 Dec 2009 17:33:48 UTC</pubDate>
  <description>
     BitBucket provides Mercurial hosting.  It&#39;s kind of a pain to have to provide a username/password on every pull or push. So, just add something like this to your &lt;code&gt;~/.hgrc&lt;/code&gt; file and make sure the permissions on the file are such that nobody else can read it.&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
[auth]
bitbucket.prefix = bitbucket.org/markd2
bitbucket.username = markd2
bitbucket.password = B4dg3rzRuL3
bitbucket.schemes = http https
&lt;/pre&gt;

So now when you do a

&lt;pre&gt;
% hg push https://bitbucket.org/markd2/borkfit
&lt;/pre&gt;

no need to authorize.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=401</guid>
</item>

<item>
  <title>Ignore files (Mercurial-&gt;General)</title>
  <pubDate>Fri, 25 Dec 2009 16:57:25 UTC</pubDate>
  <description>
     Tired of build directories or .DS_Store files showing up in &lt;code&gt;hg status&lt;/code&gt;?  Make a &lt;code&gt;.hgignore&lt;/code&gt; at the top level of your repository.  It supports glob and regex, and plain names.  &lt;code&gt;man hgignore&lt;/code&gt; for more details.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=400</guid>
</item>

<item>
  <title>Trimming whitespace from ends of a string (NSString-&gt;General)</title>
  <pubDate>Thu, 24 Dec 2009 23:26:04 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;    NSString *ook = @&#34;\n \t\t hello there \t\n  \n\n&#34;;
    NSString *trimmed =
        [ook stringByTrimmingCharactersInSet:
                 [NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSLog(@&#34;trimmed: &#39;%@&#39;&#34;, trimmed);
&lt;/pre&gt;

produces

&lt;pre&gt;
2009-12-24 18:24:42.431 trim[6799:903] trimmed: &#39;hello there&#39;
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=399</guid>
</item>

<item>
  <title>Beware BOOL results from objc_msgSend (Objective-C-&gt;Random)</title>
  <pubDate>Tue, 17 Nov 2009 14:04:33 UTC</pubDate>
  <description>
     Courtesy of David Philip Oster, from GTMNSEnumerator+Filter.m:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
// We must take care here, since Intel leaves junk in high bytes of return register
// for predicates that return BOOL.
// For details see: 
// &lt;a href=&#34;http://developer.apple.com/legacy/mac/library/documentation/MacOSX/Conceptual/universal_binary/universal_binary_tips/universal_binary_tips.html#/&#34;&gt;unibin chapter and verse&lt;/a&gt; (link currently broken courtesy of Apple)
// and
//&lt;a href=&#34;http://www.red-sweater.com/blog/320/abusing-objective-c-with-class#comment-83187&#34;&gt;comment at red-sweater&lt;/a&gt;.
- (BOOL)filterObject:(id)obj returning:(id *)resultp {
  *resultp = obj;
  return ((BOOL (*)(id, SEL, id))objc_msgSend)(obj, operation_, object_);
}
&lt;/pre&gt;

The explicit cast to the expected return value gets rid of the junk.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=398</guid>
</item>

<item>
  <title>Lie in wait for a launching process (gdb-&gt;General)</title>
  <pubDate>Mon, 24 Aug 2009 21:51:24 UTC</pubDate>
  <description>
     Attaching to a running process is pretty nifty, handy for debugging daemons started by launchd. But you miss all the fun stuff that happens at program launch before you you can attach to it.&lt;br&gt;&lt;br&gt;&lt;p&gt;

The &lt;code&gt;attach&lt;/code&gt; command&#39;s &lt;code&gt;-waitfor&lt;/code&gt; option to make gdb lie in wait for a launching process:

&lt;pre&gt;
% gdb /some/app/blah
(gdb) attach -waitfor blah
&lt;/pre&gt;

Now when a &lt;code&gt;blah&lt;/code&gt; process launches, gdb will stop it and attach to it.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=397</guid>
</item>

<item>
  <title>Convert a preprocessor symbol to an NSString (General-&gt;General)</title>
  <pubDate>Tue, 11 Aug 2009 13:36:07 UTC</pubDate>
  <description>
     &lt;pre&gt;#define CONVERT_SYMBOL_TO_NSSTRING_2(x) @#x&lt;br&gt;&lt;br&gt;#define CONVERT_SYMBOL_TO_NSSTRING(x) CONVERT_SYMBOL_TO_NSSTRING_2(x)

NSString *version = CONVERT_SYMBOL_TO_NSSTRING (BUILD_NUMBER);
&lt;/pre&gt;

(Thanks to TVL for helping me figure this one out)&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=396</guid>
</item>

<item>
  <title>Running a particular architecture (Tools-&gt;Hacks)</title>
  <pubDate>Mon, 01 Jun 2009 16:53:59 UTC</pubDate>
  <description>
     otest is kind of annoying that it tries to run the 64 bit version of your unit tests, especially if you don&#39;t have any. Typically you&#39;d get an error like&lt;br&gt;&lt;br&gt;
&lt;blockquote&gt;&lt;code&gt;2009-06-01 12:49:29.447 otest[70099:203] *** NSTask: Task create for path &#39;/blah/blah/blah&#39; failed: 8, &#34;Exec format error&#34;.  Terminating temporary process.&lt;/code&gt;&lt;/blockquote&gt;

You can force otest to run a particular architecture with the arch command:

&lt;pre&gt;
%  arch -arch i386 /Developer/Tools/otest build/Debug/Snoogle.octest
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=395</guid>
</item>

<item>
  <title>Creating a disk image from the command line (Unix-&gt;General)</title>
  <pubDate>Fri, 09 Jan 2009 21:58:44 UTC</pubDate>
  <description>
     &lt;pre&gt;% hdiutil create -ov -imagekey zlib-level=9 -fs HFS+ -format UDZO -scrub -srcfolder /Path/To/The/Goodies fooby.dmg&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=394</guid>
</item>

<item>
  <title>Increasing the length of the "Open Recent" menu (NSDocument-&gt;General)</title>
  <pubDate>Sat, 29 Nov 2008 19:18:31 UTC</pubDate>
  <description>
     10-15 items not enough for your &#34;Open Recent&#34; menu of a favorite app?  Set the app&#39;s NSRecentDocumentsLimit default to something more to your liking:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;defaults write com.flyingmeat.acorn NSRecentDocumentsLimit 137&lt;/pre&gt;

(thanks to Gus Mueller for this one)&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=393</guid>
</item>

<item>
  <title>emacs registers (emacs-&gt;General)</title>
  <pubDate>Fri, 21 Nov 2008 02:27:11 UTC</pubDate>
  <description>
     Stick something into a register:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
(select stuff)
C-x r x 1
&lt;/pre&gt;

where &#34;1&#34; is the register identifier.

&lt;p&gt;

Getting stuff out of a register:

&lt;pre&gt;
C-x r g 1
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=392</guid>
</item>

<item>
  <title>gdb'ing specific architectures (gdb-&gt;Debugging)</title>
  <pubDate>Fri, 31 Oct 2008 23:35:56 UTC</pubDate>
  <description>
     With a fat binary (32/64bit), gdb picks the 64 bit version.  If you&#39;re trying to debug a 32-bit unit test on the command-line though, the 64-bitness of /Developer/Tools/otest gets in the way:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;&lt;b&gt;% gdb /Developer/Tools/otest&lt;/b&gt;
2008-10-31 19:29:50.834 otest[711:813] Error loading
/blah/blah/blah/build/Debug/Tests.octest/Contents/MacOS/Tests:
dlopen(/blah/blah/blah/build/Debug/Tests.octest/Contents/MacOS/Tests,
265): no suitable image found.  Did find:
        /blah/blah/blah/build/Debug/Tests.octest/Contents/MacOS/Tests:
        mach-o, but wrong architecture
2008-10-31 19:29:50.887 otest[711:813] The test bundle at
build/Debug/Tests.octest could not be loaded because it is built for a
different architecture than the currently-running test rig (which is
running as unknown).
2008-10-31 19:29:50.904 otest[714:203] *** NSTask: Task create for
path &#39;/blah/blah/blah/build/Debug/Tests.octest/Contents/MacOS/Tests&#39;
failed: 8, &#34;Exec format error&#34;.  Terminating temporary process.&lt;/pre&gt;

You can supply a -arch flag to pick what you want:

&lt;pre&gt;&lt;b&gt;% gdb -arch i386 /Developer/Tools/otest&lt;/b&gt;&lt;/pre&gt;

And then debug your 32-bit unit test.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=391</guid>
</item>

<item>
  <title>Balance a tag in SGML mode (emacs-&gt;Random)</title>
  <pubDate>Sat, 11 Oct 2008 13:33:15 UTC</pubDate>
  <description>
     &lt;pre&gt;C-/&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=390</guid>
</item>

<item>
  <title>Making "edit all in scope" work (Xcode-&gt;Hacks)</title>
  <pubDate>Sat, 23 Aug 2008 14:27:00 UTC</pubDate>
  <description>
     Xcode&#39;s &#34;Edit All in Scope&#34; feature is inexplicably tied to visible syntax colorization (actually, only Edit All in Scope for object pointers is tied to this, scalar variables and pointers work fine otherwise).  So if you&#39;re not  getting the Edit All in Scope menu item to enable, make sure &#34;Color indexed Symbols&#34; is turned on in the Xcode &#34;Fonts and Colors&#34; preferences.&lt;br&gt;&lt;br&gt;
&lt;p&gt;

This advice brought to you by a DTS incident.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=389</guid>
</item>

<item>
  <title>Changing __MyCompanyName__ (Xcode-&gt;Hacks)</title>
  <pubDate>Fri, 25 Jul 2008 13:16:07 UTC</pubDate>
  <description>
     You&#39;ve probably noticed that source files generated from within XCode include a comment block header:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;//
//  TapDance.h
//  Groovilicous
//
//  Created by markd on 7/25/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//&lt;/pre&gt;

With the __MyCompanyName__ placeholder.  There is no UI to change this, for obvious reasons.  (Why would &lt;b&gt;anyone&lt;/b&gt; want to easily and conveniently change something they&#39;ll otherwise need to edit in each and every source file they create.  That&#39;s unpossible).  The obvious solution is to drop to the terminal and run the straightforward command:

&lt;pre&gt;% defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions &#39;{&#34;ORGANIZATIONNAME&#34; = &#34;Borkware&#34;;}&#39;&lt;/pre&gt;

Seemple, no?  Zee trick, she is doone.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=388</guid>
</item>

<item>
  <title>Seeing extended attributes with 'ls' (Unix-&gt;General)</title>
  <pubDate>Fri, 25 Jul 2008 00:54:04 UTC</pubDate>
  <description>
     Sometimes you see an @ after the directory permissions in an &lt;code&gt;ls -l&lt;/code&gt;:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;% ls -l ~/junk/SnapshotRepository.sparseimage
-rw-r--r--@ 1 markd  markd  135270400 Jul 24 20:38 /Users/markd/junk/SnapshotRepository.sparseimage&lt;/pre&gt;

That means there&#39;s some extended attributes.  use &lt;code&gt;ls -l@ to see them&lt;/code&gt;:

&lt;pre&gt;% ls -l@ ~/junk/SnapshotRepository.sparseimage
-rw-r--r--@ 1 markd  markd  135270400 Jul 24 20:38 /Users/markd/junk/SnapshotRepository.sparseimage
	com.apple.diskimages.fsck	       20 &lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=387</guid>
</item>

<item>
  <title>Turning off Xcode's "Undo past save" warning (Xcode-&gt;General)</title>
  <pubDate>Mon, 14 Jul 2008 00:46:58 UTC</pubDate>
  <description>
     For some reason, Xcode thinks that an undo past the last save is something horrible that you need to be warned about.  After living with unstable software, cmd-S is a habit, and undoing past it is No Big Deal.  Really.  Here&#39;s how to turn it off:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;% defaults write com.apple.Xcode XCShowUndoPastSaveWarning NO&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=386</guid>
</item>

</channel>
</rss>
