<?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>Sat, 12 May 2012 20:01:46 UTC</pubDate>
  <link>http://borkware.com</link>

<item>
  <title>Enabling ARC (General-&gt;General)</title>
  <pubDate>Sat, 12 May 2012 20:01:46 UTC</pubDate>
  <description>
     Turn on ARC at the command line by feeding the compiler the &lt;code&gt;-fobjc-arc&lt;/code&gt; flag.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=528</guid>
</item>

<item>
  <title>Git Logging Options (git-&gt;General)</title>
  <pubDate>Fri, 04 May 2012 22:28:25 UTC</pubDate>
  <description>
     &lt;code&gt;git log [options] [--] [path]&lt;/code&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;
&lt;ul&gt;
  &lt;li&gt; &lt;code&gt;-p&lt;/code&gt; &amp;mdash; show the diff (patch)
  &lt;li&gt; &lt;code&gt;-#&lt;/code&gt; &amp;mdash; limit output (e.g. &lt;code&gt;-23&lt;/code&gt; to last 23 entries)
  &lt;li&gt; &lt;code&gt;--since / --until&lt;/code&gt; &amp;mdash; commits more recent (or older) than given date
  &lt;li&gt; &lt;code&gt;--stat&lt;/code&gt; &amp;mdash; abbreviated stats (adds/deletes, modified files)
  &lt;li&gt; &lt;code&gt;--pretty=&lt;i&gt;thing&lt;/i&gt;&lt;/code&gt; &amp;mdash; Make output pretty. Things include oneline, short, medium, full, fuller, (no fullest), email, raw, format:, tformat:&lt;string&gt; . use tformat if you want a newline at the end of the log
  &lt;li&gt; &lt;code&gt;--graph&lt;/code&gt; &amp;mdash; draw those funky git branch gtaphs
  &lt;li&gt; &lt;code&gt;--author / --committer&lt;/code&gt; &amp;mdash; filter on specific dude / dudette
  &lt;li&gt; &lt;code&gt;--grep&lt;/code&gt; &amp;mdash; filter on keywords in commit messages
  &lt;li&gt; &lt;code&gt;--all-match&lt;/code&gt; &amp;mdash; Turn multiple predicates from OR into AND
&lt;/ul&gt;
&lt;p&gt;
&lt;b&gt;Format Options&lt;/b&gt;
&lt;p&gt;
&lt;ul&gt;
  &lt;li&gt; &lt;code&gt;%H / %h&lt;/code&gt; &amp;mdash; hash (shortened)
  &lt;li&gt; &lt;code&gt;%T / %t&lt;/code&gt; &amp;mdash; tree hash (shortened)
  &lt;li&gt; &lt;code&gt;%P / %p&lt;/code&gt; &amp;mdash; parent hash (shortened)
  &lt;li&gt; &lt;code&gt;%an / %ae / %ad / %ar&lt;/code&gt; &amp;mdash; Author name, email, date (relative)
  &lt;li&gt; &lt;code&gt;%cd / %ce / %cd / %cr&lt;/code&gt; &amp;mdash; Committer name, email, date (relative)
  &lt;li&gt; &lt;code&gt;%n&lt;/code&gt; &amp;mdash; newline
&lt;/ul&gt;

&lt;p&gt;
Date format can be specific (1961-01-13), or relative (&#34;4 years 23 months&#34;).  Can replace spaces with dots: 4.years.23.months.  The actual format is undocumented (OF COURSE), but you can look at the &lt;a href=&#34;https://github.com/git/git/blob/master/date.c&#34;&gt;approxidate code&lt;/a&gt;.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=527</guid>
</item>

<item>
  <title>Three faces of git diff (git-&gt;General)</title>
  <pubDate>Fri, 04 May 2012 19:29:50 UTC</pubDate>
  <description>
     &lt;code&gt;git diff&lt;/code&gt; shows changes made since the file was last staged.  If you make changes, stage them, then make more changes, this only shows you the more changes&lt;br&gt;&lt;br&gt;&lt;p&gt;

&lt;code&gt;git diff --staged&lt;/code&gt; shows changes made to the file when it was staged, diffs against the committed version it&#39;s based off of.  It doesn&#39;t include any changes you&#39;ve made since staging.
&lt;p&gt;
&lt;code&gt;git diff HEAD&lt;/code&gt; (where HEAD is the name of a commit - HEAD to compare with the latest commit, or a branch name to compare to the tip of that branch.  In essence, unions &lt;code&gt;git diff&lt;/code&gt; and &lt;code&gt;git diff HEAD&lt;/code&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=526</guid>
</item>

<item>
  <title>Password-less github gitting (git-&gt;General)</title>
  <pubDate>Fri, 04 May 2012 17:25:05 UTC</pubDate>
  <description>
     Typing in your username and password for github is annoying.  You&#39;ll need  to do the ssh key dance.  &lt;a href=&#34;http://help.github.com/mac-set-up-git/&#34;&gt;instructions here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
&lt;p&gt;

If your current checkout is via https (you can figure that out by doing &lt;code&gt;git config -l&lt;/code&gt; (ell) and looking at the &lt;code&gt;remote.origin.url&lt;/code&gt;.  If it&#39;s &lt;code&gt;https&lt;/code&gt; you&#39;re not going to use your ssh keys.  You&#39;ll need to change it.
&lt;p&gt;

If it was originally:
&lt;p&gt;
&lt;code&gt;remote.origin.url=https://github.com/someuser/GroovyProject.git&lt;/code&gt;&lt;/code&gt;
&lt;p&gt;
You&#39;d do:
&lt;p&gt;
&lt;code&gt;% git config remote.origin.url git@github.com:someuser/GroovyProject.git&lt;/code&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=525</guid>
</item>

<item>
  <title>git "revert" (git-&gt;General)</title>
  <pubDate>Mon, 23 Apr 2012 19:16:50 UTC</pubDate>
  <description>
     To remove uncommitted changes so you can pull without complaint (revert in svn-speak):&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
% git checkout  filename-to-revert
&lt;/pre&gt;

This checks the file out from HEAD, removing the local modificaiton.  (put &lt;code&gt;--&lt;/code&gt; before the file name in case you have a branch named the same as the file)&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=524</guid>
</item>

<item>
  <title>Seeing entitlement and certification information (Provisioning Hell-&gt;Hacks)</title>
  <pubDate>Fri, 13 Apr 2012 22:14:11 UTC</pubDate>
  <description>
     Sometimes it&#39;s useful to see what certificate was used for signing, and what entitlements are in your app.  The &lt;code&gt;codesign&lt;/code&gt; tool does that.&lt;br&gt;&lt;br&gt;
How to use:

&lt;pre&gt;
% cd ~/Library/Developer/Xcode/Archives/$DATE/Campwhere.xcarchive/Products/Applications
% codesign -dvvv codesign -dvvv ./Campwhere.app
% codesign -d --entitlements - ./Campwhere.app
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=523</guid>
</item>

<item>
  <title>Describe table in sqlite3 (sqlite3-&gt;General)</title>
  <pubDate>Thu, 12 Apr 2012 16:06:50 UTC</pubDate>
  <description>
     To see the table structure, use &lt;code&gt;.schema&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
sqlite&amp;gt; &lt;b&gt;.schema camp&lt;/b&gt;
CREATE TABLE camp (code INTEGER, label TEXT, state TEXT, type TEXT, phone TEXT, sites INTEGER, nforg TEXT, lat NUMERIC, lon NUMERIC, elevation NUMERIC, fee TEXT);
CREATE INDEX pkdex ON camp (code);
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=522</guid>
</item>

<item>
  <title>Basic NSURLConnection delegate methods (NSURL-&gt;General)</title>
  <pubDate>Fri, 06 Apr 2012 18:13:29 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;- (void) connection: (NSURLConnection *) connection
 didReceiveResponse: (NSURLResponse *) response;

- (void) connection:  (NSURLConnection *) connection  didReceiveData: (NSData *) data;

- (void) connection: (NSURLConnection *) connection  didFailWithError: (NSError *) error;

- (void) connectionDidFinishLoading: (NSURLConnection *) connection;
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=521</guid>
</item>

<item>
  <title>Only allowing numbers in a text field (UITextField-&gt;General)</title>
  <pubDate>Thu, 05 Apr 2012 01:09:03 UTC</pubDate>
  <description>
     Sometimes you need a more general keyboard for a numeric-only text field.  You can do something like this in a delegate method:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
- (BOOL) textField: (UITextField *) textField
  shouldChangeCharactersInRange: (NSRange) range
              replacementString: (NSString *) string {
    NSString *resultingString = [textField.text stringByReplacingCharactersInRange: range
                                          withString: string];
    if (resultingString.length == 0) return YES;
    NSScanner *scanner = [NSScanner scannerWithString: resultingString];

    float throwaway;
    BOOL scansFloat = [scanner scanFloat: &amp;throwaway];
    BOOL atEnd = [scanner isAtEnd];

    return scansFloat &amp;&amp; atEnd;

} // shouldChangedCharacersInRanges
&lt;/pre&gt;

(thanks to Frank Shearer, from a &lt;a href=&#34;http://stackoverflow.com/questions/1320295/iphone-how-to-check-that-a-string-is-numeric-only/1750872#1750872&#34;&gt;SO&lt;/a&gt; post)&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=520</guid>
</item>

<item>
  <title>Getting notified of UITextField changes (UITextField-&gt;General)</title>
  <pubDate>Wed, 04 Apr 2012 23:00:48 UTC</pubDate>
  <description>
     Easiest way is to hook up the &lt;i&gt;Editing Changed&lt;/i&gt; (&lt;b&gt;NOT&lt;/b&gt; &lt;i&gt;Value Changed&lt;/i&gt;) action.&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=519</guid>
</item>

<item>
  <title>Rsyncing a directory hierarchy from one machine to another (Unix-&gt;General)</title>
  <pubDate>Wed, 07 Mar 2012 21:28:43 UTC</pubDate>
  <description>
     I&#39;m moving a bunch of movie files from one machine to another.  I used this rsync command to copy it from the remote machine to the local one to the directory &lt;code&gt;/Volumes/Media2&lt;/code&gt;&lt;br&gt;&lt;br&gt;&lt;pre&gt;
% rsync -avz -e ssh --progress &#39;biggun.local:/Volumes/Video/AppleTV\ Videos/Exercise&#39; /Volumes/Media2
&lt;/pre&gt;
I can never remember what the flags mean, so:
&lt;ul&gt;
&lt;li&gt; -a : archive mode (recursive, also preserve symlinks, permissions, owner and group)
&lt;li&gt; -v : verbose
&lt;li&gt; -z : compress for transport
&lt;li&gt; -e ssh : use ssh for the transport pipeline
&lt;li&gt; --progress : see progress info
&lt;/ul&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=518</guid>
</item>

<item>
  <title>Preventing an app from opening stale windows (Unix-&gt;General)</title>
  <pubDate>Tue, 06 Mar 2012 16:37:53 UTC</pubDate>
  <description>
     Lion introduced the idea that apps restore all their windows that were last open.  Sometimes that&#39;s wonderful.  For some apps, it&#39;s maddening.  You can tweak individual apps by setting a default:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
% defaults write com.bignerdranch.bigshow NSQuitAlwaysKeepsWindows -bool false
&lt;/pre&gt;

(thanks to Step Christopher for this one)&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=517</guid>
</item>

<item>
  <title>Block that measures time. (Tools-&gt;General)</title>
  <pubDate>Sun, 26 Feb 2012 21:59:04 UTC</pubDate>
  <description>
     Sometimes you want to do a quick measurement of a chunk of code to see how long it takes, and you don&#39;t want to crank up  &lt;strike&gt;gprof&lt;/strike&gt; &lt;strike&gt;Shark&lt;/strike&gt; Instruments to do it.  &lt;code&gt;mach_absolute_time&lt;/code&gt; is the finest-grained timer in the system.  Here&#39;s a little utility to time a block:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;

#import &amp;lt;mach/mach_time.h&amp;gt;  // for mach_absolute_time() and friends

CGFloat BWTimeBlock (void (^block)(void)) {
    mach_timebase_info_data_t info;
    if (mach_timebase_info (&amp;info) != KERN_SUCCESS) return -1;

    uint64_t start = mach_absolute_time ();
    block ();
    uint64_t end = mach_absolute_time ();
    uint64_t elapsed = end - start;

    uint64_t nanos = elapsed * info.numer / info.denom;
    return (CGFloat)nanos / NSEC_PER_SEC;

} // BWTimeBlock

&lt;/pre&gt;

And you would use it like:

&lt;pre&gt;    NSString *thing1 = @&#34;hi&#34;;
    NSString *thing2 = @&#34;hello there&#34;;

    time = BWTimeBlock(^{
            for (int i = 0; i &lt; LOOPAGE; i++) {
                [thing1 isEqualTo: thing2];
            }
        });
    printf (&#34;equalTo time: %f\n&#34;, time);
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=516</guid>
</item>

<item>
  <title>Turn off the Lion "autorepeat shows accent chooser" (General-&gt;General)</title>
  <pubDate>Thu, 09 Feb 2012 22:50:45 UTC</pubDate>
  <description>
     I actually want my characters to autorepeat rather than seeing the accent chooser.  Run this in the terminal, and restart affected apps:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;defaults write -g ApplePressAndHoldEnabled -bool false&lt;/pre&gt;

(thanks to Paul Kafasis)&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=515</guid>
</item>

<item>
  <title>Triggering a low-memory warning on the device (Debugging-&gt;General)</title>
  <pubDate>Fri, 03 Feb 2012 19:34:35 UTC</pubDate>
  <description>
     You can trigger a low-memory warning in the simulator, but sometimes you use one of the myriad of APIs that aren&#39;t supported in the simulator, but you still need to track down something ultimately triggered by a low-memory warning.&lt;br&gt;&lt;br&gt;
&lt;p&gt;

Put this somewhere convenient to trigger  - in a timer, under a button, or something.  Obviously, you don&#39;t want to ship with it.

&lt;pre&gt;[[UIApplication sharedApplication] performSelector: @selector(_performMemoryWarning)];&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=514</guid>
</item>

<item>
  <title>Using a nib for a tableview cell (UITableView-&gt;General)</title>
  <pubDate>Sat, 28 Jan 2012 02:01:55 UTC</pubDate>
  <description>
     You can use a nib file for table view cells pretty easily in iOS5.&lt;br&gt;&lt;br&gt;
&lt;p&gt;

1) Make a nib with a single object at the top, a &lt;code&gt;UITableViewCell&lt;/code&gt;.  Lay it out as you wish.  I use view tags to get to the objects contained therein.

&lt;pre&gt;
enum {
    kTermLabelTag = 1,
    kDetailLabelTag = 2
};
&lt;/pre&gt;

&lt;p&gt;

2) Register the nib for a cell reuse identifier.  I do it in my &lt;code&gt;-viewDidLoad&lt;/code&gt;.

&lt;pre&gt;
static NSString *g_cellReuseIdentifier = @&#34;BWLookupCellReuseIdentifier&#34;; // file global

...

    UINib *nib = [UINib nibWithNibName: @&#34;BWLookupTableViewCell&#34;  bundle: nil];
    [self.resultsView registerNib: nib
         forCellReuseIdentifier: g_cellReuseIdentifier];
&lt;/pre&gt;

3) Dequeue the cell as usual

&lt;pre&gt;
    UITableViewCell *cell =
        [tableView dequeueReusableCellWithIdentifier: g_cellReuseIdentifier];

    if (!cell) {
        cell = [[UITableViewCell alloc]
                   initWithStyle: UITableViewCellStyleSubtitle
                   reuseIdentifier: g_cellReuseIdentifier];
    }
&lt;/pre&gt;

4) Dig into the cell with the tags, and go nuts

&lt;pre&gt;
    UILabel *termLabel = (UILabel *)[cell viewWithTag: kTermLabelTag];
    UILabel *detailLabel = (UILabel *)[cell viewWithTag: kDetailLabelTag];

    termLabel.text = termString;
    detailLabel.text = definition;
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=513</guid>
</item>

<item>
  <title>Converting degrees to radians and back (Graphics-&gt;General)</title>
  <pubDate>Thu, 29 Dec 2011 23:31:44 UTC</pubDate>
  <description>
     Most programming interfaces that deal with angles talk in radians (2 pi radians in a circle), like &lt;code&gt;CGAffineTransformRotate&lt;/code&gt;.  I personally think better in degrees (360 degrees in a circle).&lt;br&gt;&lt;br&gt;&lt;p&gt;

Convert degrees to radians by multiplying by &lt;code&gt;180 / pi&lt;/code&gt;.
&lt;p&gt;
Convert radians to degrees by multiplying by &lt;code&gt;pi / 180&lt;/code&gt;
&lt;p&gt;

I have a couple of #defines I stick into a common header for projects that need it;
&lt;pre&gt;#define BWDegToRad(d)   ((d) * M_PI / 180.0)
#define BWRadToDeg(r)   ((r) * 180 / M_PI)
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=512</guid>
</item>

<item>
  <title>Push/pop CGContext state (Graphics-&gt;General)</title>
  <pubDate>Thu, 29 Dec 2011 02:56:29 UTC</pubDate>
  <description>
     &lt;pre&gt;CGContextRef context = ...;&lt;br&gt;&lt;br&gt;...
CGContextSaveGState (context); {
    [drawable drawWithContext: context
              inRect: bounds
              withMetrics: self.metrics]; // or whatever drawing you&#39;re doing
} CGContextRestoreGState (context);
&lt;/pre&gt;

Edit: Gus Meuller of &lt;a href=&#34;http://flyingmeat.com&#34;&gt;Flying Meat&lt;/a&gt; fame has a block-based utility that does this:


&lt;pre&gt;void FMCGContextHoldGState (CGContextRef context, void (^block)()) {
    CGContextSaveGState(context); {
        block ();
    } CGContextRestoreGState(context);
}
&lt;/pre&gt;

and if you&#39;re wanting to do something similar with &lt;code&gt;NSGraphicsContext&lt;/code&gt;s:

&lt;pre&gt;void FMNSContextHoldGState (void (^block)()) {
    [NSGraphicsContext saveGraphicsState]; {
        block ();
    } [NSGraphicsContext restoreGraphicsState];
}
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=511</guid>
</item>

<item>
  <title>Sort case-insensitive (emacs-&gt;General)</title>
  <pubDate>Mon, 26 Dec 2011 03:42:07 UTC</pubDate>
  <description>
     &lt;code&gt;M-x sort-lines&lt;/code&gt; uses a case-sensitive search.   When that sucks, you can tell emacs to be case insensitive (globally) by doing &lt;code&gt;M-x set-variable RET sort-fold-case RET t&lt;/code&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=510</guid>
</item>

<item>
  <title>UITableView section header titles (UITableView-&gt;General)</title>
  <pubDate>Mon, 26 Dec 2011 01:45:23 UTC</pubDate>
  <description>
     UITableView won&#39;t display its groovy section headers (or footers) until you supply them via the datasource:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
- (NSString *) tableView: (UITableView *) tableview
 titleForHeaderInSection: (NSInteger) section {
    NSArray *sections = [BWTermStorage sections];
    return [sections objectAtIndex: section];
} // titleForHeaderInSection
&lt;/pre&gt;

You can return a title for a footer.  

&lt;p&gt;

You can also return a view:

&lt;pre&gt;
- (UIView *) tableView: (UITableView *) tableView 
    viewForHeaderInSection: (NSInteger) section;
&lt;/pre&gt;&lt;br&gt;
  </description>
  <guid isPermaLink='false'>http://borkware.com/quickies/single?id=509</guid>
</item>

</channel>
</rss>

