<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>ramblings, musing and code snippets from shawn veader</description><title>the codemonky</title><generator>Tumblr (3.0; @veader)</generator><link>http://codemonky.com/</link><item><title>Clearing Cached Credentials on the iPhone</title><description>&lt;p&gt; My latest iPhone project hits an API to fetch data. All was well and good until I began to test with the account I was going to turn over to the Apple review folks. Turns out, switching login credentials had no effect. After digging in, I realized I had the cache policy for the credentials set to: &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
NSURLCredentialPersistenceForSession
&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;br/&gt;&lt;p&gt; So I began to hunt for a mechanism to clear this cached credential so the next request would hit the NSURLConnection delegate: &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
- (void)connection:didReceiveAuthenticationChallenge:
&lt;/code&gt;&lt;/pre&gt;
&lt;br/&gt;&lt;p&gt; I started with: &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
[[NSURLCache sharedURLCache] removeAllCachedResponses];
&lt;/code&gt;&lt;/pre&gt;
&lt;br/&gt;&lt;p&gt;But this didn’t help. So I moved onto: &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
[NSURLCredentialStorage sharedCredentialStorage]
&lt;/code&gt;&lt;/pre&gt;
&lt;br/&gt;&lt;p&gt;This lead me down trying to clear all the credentials in the storage; however, much to my surprise, this did nothing either. Hmm… Well, thinking back to browser land, I decided to hunt down any cookies that might be stashed somewhere. This lead me to:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
[NSHTTPCookieStorage sharedHTTPCookieStorage]
&lt;/code&gt;&lt;/pre&gt;
&lt;br/&gt;&lt;p&gt;After clearing out all the cookies for the domain I was hitting, I finally got the request to prompt for validation credentials again. I’m pretty sure all parts of this aren’t needed, but I’m being overly paranoid at this point. The resulting code can be found at this &lt;a href="http://gist.github.com/559071"&gt;gist&lt;/a&gt;&lt;/p&gt;</description><link>http://codemonky.com/post/1042548386</link><guid>http://codemonky.com/post/1042548386</guid><pubDate>Tue, 31 Aug 2010 10:17:00 -0400</pubDate></item><item><title>My dates leak memory</title><description>&lt;p&gt;
Doing some iPhone hacking recently and poking around the leaks instrument. Noticed a call to NSDate causing some leaking. Getting to the meat of it was this code block:
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss zzzz"];
NSDate *dateTime = [formatter dateFromString:newTimeString];
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
The leaks instrument pointed to the call to -dateFromString: on the NSDateFormatter doing the leak.
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;
… &lt;blink&gt; …
&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;
On the core class? Yup, did some Googling and found some other folks with the same problem. Here was the best answer I found: &lt;br/&gt;&lt;a href="http://thegothicparty.com/dev/article/nsdateformatter-memory-leak/"&gt;http://thegothicparty.com/dev/article/nsdateformatter-memory-leak/&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Evidently, the time zone piece of the format string was leaking memory.
&lt;/p&gt;

&lt;p&gt;
Turns out I had another bug in my time formatting code so I ended up switching the “zzzz” for “Z” and my memory leak and bug went away.
&lt;/p&gt;

&lt;p&gt;
So if you are converting dates with timezones, see if you can use the “Z” format not the “z”, even if you have to munge your string a bit to get that.
&lt;/p&gt;

&lt;p&gt;
For more information on the formatting strings:&lt;br/&gt; &lt;a href="http://unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns"&gt;http://unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns&lt;/a&gt; &lt;/p&gt;</description><link>http://codemonky.com/post/878218624</link><guid>http://codemonky.com/post/878218624</guid><pubDate>Fri, 30 Jul 2010 00:33:20 -0400</pubDate></item><item><title>

bummed i missed worldwide pinhole camera day yesterday (on my birthday, no less). maybe photojojo...</title><description>&lt;p&gt;&lt;a href="http://www.flickr.com/photos/aranjuez_chou/4542466911/in/pool-pinholers"&gt;&lt;img src="http://farm5.static.flickr.com/4056/4542466911_4062120e2c.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;bummed i missed worldwide pinhole camera day yesterday (on my birthday, no less). maybe photojojo will give me a pinhole so i can fix that problem.&lt;/p&gt;

&lt;p&gt;i really dig the wide aspect ratio of this guys work. above photo from &lt;a href="http://www.flickr.com/photos/aranjuez_chou/"&gt;aranjuez chou&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;see what i’m talking about &lt;a href="http://photojojo.tumblr.com/post/551383022/were-giving-away-50-pinhole-cameras-did-you"&gt;here&lt;/a&gt;&lt;/p&gt;</description><link>http://codemonky.com/post/551433249</link><guid>http://codemonky.com/post/551433249</guid><pubDate>Mon, 26 Apr 2010 16:04:00 -0400</pubDate><category>photojojo</category></item><item><title>photojojo:


Photojojo is running a CRAZY experiment for the...</title><description>&lt;img src="http://26.media.tumblr.com/tumblr_kzin4pjt481qz7ymyo1_r1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;a href="http://photojojo.tumblr.com/post/459112719/photojojo-is-running-a-crazy-experiment-for-the" class="tumblr_blog"&gt;photojojo&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photojojo is running a CRAZY experiment for the next 3 hours!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reblog this post before 4pm EDT &lt;/strong&gt;on 3/19 (1 pm PDT) and the amazing &lt;a href="http://photojojo.com/store/awesomeness/instax-camera/crazy-tumblr"&gt;Instax Instant Camera&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;&lt;strong&gt;price &lt;/strong&gt;&lt;strong&gt;goes down 10 cents for EVERY REBLOG!&lt;br/&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;R&lt;/strong&gt;&lt;strong&gt;eblog,&lt;/strong&gt; &lt;strong&gt;&lt;a href="http://photojojo.com/store/awesomeness/instax-camera/crazy-tumblr"&gt;check the price&lt;/a&gt; &lt;/strong&gt;&amp; snap one up before they’re gone. Price goes back to normal @ 4pm or when they run out!&lt;/p&gt;
&lt;p&gt;&lt;small&gt;p.s. The lowest possible price is zero, no negative funny business, mister. And you should &lt;a href="http://tumblr.com/follow/photojojo"&gt;follow Photojojo on Tumblr&lt;/a&gt; cuz it’s awesome!&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE: We’re running out of cameras! The response is crrrrrazy. There’s no way we’ll have stock in an hour.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;</description><link>http://codemonky.com/post/459171633</link><guid>http://codemonky.com/post/459171633</guid><pubDate>Fri, 19 Mar 2010 13:40:23 -0400</pubDate></item><item><title>iPhone Dev : Determining Text Height</title><description>&lt;p&gt;
OK, so you’re developing your application and programmatically laying out your UILabel. You want to know the height the label will ultimately be, so you can set the frame accordingly. You poke around and find the following method buried in NSString.
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
sizeWithFont:forWidth:lineBreakMode:
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
Thinking you’ve struck gold, you proceed. Once you run your app you realize this method will never give you a height for more than one line. This has to be a bug, you think to yourself. 
&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://openradar.appspot.com/radar?id=74427"&gt;http://openradar.appspot.com/radar?id=74427&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Nope! Apple says it works as intended. This seems like a waste because you can get the same information out of UIFont. Sigh.
&lt;/p&gt;

&lt;p&gt;
You end up having to go with NSString’s sizeWithFont:constrainedToSize:lineBreakMode: method and using a constraint with unlimited height. Here’s the full scoop.
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
// determine your width before and put it here
CGSize constrainedSize = CGSizeMake(width, MAXFLOAT);
UIFont *textFont = [UIFont systemFontOfSize:13.0f];
NSString *text = @"Some very long string goes here...";
CGSize textSize = [text sizeWithFont:textFont 
                   constrainedToSize:constrainedSize 
                       lineBreakMode:UILineBreakModeWordWrap];
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
Hopefully some day Apple will fix that first method to do the sane thing, but don’t hold your breath.
&lt;/p&gt;</description><link>http://codemonky.com/post/426406617</link><guid>http://codemonky.com/post/426406617</guid><pubDate>Thu, 04 Mar 2010 11:07:00 -0500</pubDate></item><item><title>Running the iPhone 3.2 Beta... First Gotchas</title><description>&lt;p&gt;I installed the 3.2 beta the other day to play with the new iPad simulator. (&lt;em&gt;Neat stuff… more on that later.&lt;/em&gt;) But I tried working on one of my many half-completed iPhone apps the other night and ran into a few interesting problems. &lt;/p&gt;

&lt;p&gt;The first problem I encountered was that the credentials in my app were not saving to the user defaults. I scratched my head a few times with this but did get some good testing out of it.&lt;/p&gt;

&lt;p&gt;The second problem was the one that eventually led me to hitting Google in search of answers. After getting past some bugs I uncovered by not having user credentials, my app tried to load a standard table view. This table view has a custom cell loaded from a NIB. When the app tried to load this NIB, I was greeted with this wonderful message in the console.&lt;/p&gt;

&lt;blockquote&gt;
uncaught exception ‘NSInvalidUnarchiveOperationException’, reason: ‘*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (UITableViewCellContentView)’
&lt;/blockquote&gt;

&lt;p&gt;A few Google searches later and I found &lt;a href="http://stackoverflow.com/questions/2152321/weird-uitableviewcell-loading-exception"&gt;this response&lt;/a&gt; over on StackOverflow. However, I found it hard to believe that all of a sudden I needed to declare a class that was supposed to be built into the framework. I then started poking at XCode and the simulator and noticed something strange….&lt;/p&gt;

&lt;p&gt;I had opened my project from the console (yes, I’m *that* guy) with the “open” command as I always do. Unbeknownst to me this opened the newer XCode out of the alternate install. This turned out to be the root of all my problems. I opened /Developer/Applications/XCode.app and &lt;strong&gt;BOOM&lt;/strong&gt; everything started working again.&lt;/p&gt;

&lt;p&gt;So if you’re running dual development environments, watch out!&lt;/p&gt;</description><link>http://codemonky.com/post/372507885</link><guid>http://codemonky.com/post/372507885</guid><pubDate>Fri, 05 Feb 2010 11:23:02 -0500</pubDate></item><item><title>Obj-C Oddities</title><description>&lt;p&gt;I never seem to find enough time to be in Obj-C land long enough to develop muscle memory so there are things that consistently get me.

NSDictionary creation is backwards:

&lt;pre&gt;
NSDictionary *stuff = 
[NSDictionary dictionaryWithObjectsAndKeys:@"value1", @"key1", 
                                           @"value2", @"key2", nil];
&lt;/pre&gt; 

In Ruby-land (where I’ve been for quite some time) it would be:

&lt;pre&gt;
stuff = { :key1 =&gt; "value1", :key2 =&gt; "value2" }
&lt;/pre&gt;

&lt;b&gt;Almost forgot!&lt;/b&gt;

I also almost always forget the nil at the end of an NSDictionary or NSArray declaration.

For instance:

&lt;pre&gt;
NSArray *myList = [NSArray arrayWithObjects: @"foo", @"bar", @"baz", nil];
&lt;/pre&gt;

I continually forget that trailing nil, but it should be obvious since C is under the covers after all.&lt;/p&gt;</description><link>http://codemonky.com/post/321003062</link><guid>http://codemonky.com/post/321003062</guid><pubDate>Thu, 07 Jan 2010 00:08:36 -0500</pubDate></item><item><title>Zombies are your friend!</title><description>&lt;p&gt;No, they’re not here to eat your brain this time. They are here to &lt;i&gt;save&lt;/i&gt; it.&lt;/p&gt;

&lt;p&gt;So you’re happily coding along in Obj-C and developing the next big iPhone app. You build and run in the simulator only to see it crash and give &lt;b&gt;EXC_BAD_ACCESS&lt;/b&gt; in the console. You then spend a few minutes to a few hours (depending on how persistent you are) debugging and trying to chase down the problem (which, by the way, is usually trying to send a message to a released object). Compound this by having a multithreaded application (you are using threads, right?) and you can start to feel the frustration building.&lt;/p&gt;

&lt;p&gt;Now envision some zombies coming to help. Yes, zombies.&lt;/p&gt;

&lt;p&gt;Well… not &lt;i&gt;real&lt;/i&gt; zombies of course. &lt;/p&gt;

&lt;p&gt;&lt;br/&gt;
Objective-C was kind enough to include an awesome environment variable you can set that will leave around a dummy object for everything that is released so you can see where that &lt;b&gt;EXC_BAD_ACCESS&lt;/b&gt; is coming from.&lt;/p&gt;

&lt;p&gt;The environment variable is &lt;b&gt;NSZombieEnabled&lt;/b&gt;. Edit the executable options in XCode and create a new environment variable named &lt;b&gt;NSZombieEnabled&lt;/b&gt; and set the value to &lt;b&gt;YES&lt;/b&gt;. It should look like this:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://img.skitch.com/20090728-nt3pgp52n4dw4xps862cajr56k.jpg"/&gt;&lt;/p&gt;

&lt;p&gt;Now build and run and see what you get. Enjoy!&lt;/p&gt;</description><link>http://codemonky.com/post/150858649</link><guid>http://codemonky.com/post/150858649</guid><pubDate>Tue, 28 Jul 2009 10:06:43 -0400</pubDate></item><item><title>Animated GIFs and UIImageViews</title><description>&lt;p&gt;OK, so while building an iPhone app last night I ran into a little snag. We are using an animated GIF on the loading screen to allow the user to see something pretty while they wait. &lt;/p&gt;

&lt;p&gt;Being naive, I assumed the UIImageView would display the animated GIF. Well… I was partially right. It does display the GIF but only the first frame.&lt;/p&gt;

&lt;p&gt;Then the Google hunt began…&lt;/p&gt;

&lt;p&gt;After some searching, I had found that you can set the animatedImages property of a UIImageView to a NSArray that contains each frame of the animated GIF and then call the startAnimating method to “play” it.&lt;/p&gt;

&lt;p&gt;OK, great…. now how do I get the frames out? After more Googling I just tried Preview.app on a wild hair. I’m glad to report that it shows the animated GIF but in the drawer of the app, it also has each frame. Simply drag each of these out and boom! you’re set.&lt;/p&gt;

&lt;p&gt;Now for the code sample.&lt;/p&gt;

&lt;pre&gt;
UIImage *frame0 = [UIImage imageNamed:@"frame0.png"];
// ... more frames here ...
UIImage *frameN = [UIImage imageNamed:@"frameN.png"];

// animatedGif is a UIImageView initialized in your NIB or elsewhere.
animatedGif.animatedImages = [[NSArray alloc] initWithObjects:frame0
                                                              ....
                                                              frameN,
                                                              nil];
[animatedGif startAnimating];
&lt;/pre&gt; 

&lt;p&gt;There are a few other things you can play with like the animatedDuration and animatedRepeatCount properties. But you can figure those out.&lt;/p&gt;

&lt;p&gt;And a link to the UIImageView documentation for completeness… &lt;a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIImageView_Class/Reference/Reference.html"&gt;UIImageView&lt;/a&gt;&lt;/p&gt;</description><link>http://codemonky.com/post/129361909</link><guid>http://codemonky.com/post/129361909</guid><pubDate>Wed, 24 Jun 2009 10:00:00 -0400</pubDate></item><item><title>Must haves for Safari</title><description>&lt;p&gt;So I’m back on Safari, for the moment, (no offense Firefox) and I just wanted to pass along two plugins that you must install.&lt;/p&gt;

&lt;p&gt;&lt;br/&gt;&lt;b&gt;Click-to-Flash&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://github.com/rentzsch/clicktoflash/tree/master"&gt;http://github.com/rentzsch/clicktoflash/tree/master&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This replaces any flash on a website with a little logo that says “Flash”. If you actually want to see the flash you just click it and it loads. Works very well to keep the browser from chewing up all your computing resources running Flash. (Adobe: why is Flash so horrible?)&lt;/p&gt;

&lt;p&gt;&lt;br/&gt;&lt;b&gt;AdBlock&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://burgersoftware.com/en/safariadblock"&gt;http://burgersoftware.com/en/safariadblock&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recent addition for me but blocks ad content for a more pleasant browsing experience.&lt;/p&gt;</description><link>http://codemonky.com/post/124697120</link><guid>http://codemonky.com/post/124697120</guid><pubDate>Tue, 16 Jun 2009 13:49:00 -0400</pubDate></item><item><title>Starting down the path of objectifying C</title><description>&lt;p&gt;OK, so I’ve had my head in and out of books lately trying to learn obj-C and Cocoa. So far it’s not too bad. Kinda fun to be back into a little more strict C-style world, while still maintaining some cool OO features. &lt;/p&gt;

&lt;p&gt;My biggest gotchas/gripes I’ve found so far? &lt;/p&gt;

&lt;p&gt;1) Having to add a nil to the end of a declared NSArray or NSDictionary (or their mutable variants).&lt;/p&gt;

&lt;pre&gt;
[NSArray arrayWithObjects:@"1", @"2", @"3", nil];
&lt;/pre&gt;

&lt;p&gt;That just seems like something that could be abstracted away for you…&lt;/p&gt;

&lt;p&gt;2) Declaring a NSDictionary with keys and values is backward from what I would expect from Ruby land.&lt;/p&gt;

&lt;pre&gt;
// what I expect
[NSDictionary dictionaryWithObjectsAndKeys:
              @"key1", @"value1", @"key2", @"value2",nil];
// what reality is
[NSDictionary dictionaryWithObjectsAndKeys:
              @"value1", @"key1", @"value2", @"key2",nil];
&lt;/pre&gt;

&lt;p&gt;3) And as you can see from the examples above… the biggest gotcha of all is that to declare a string you have to prefix it with @.&lt;/p&gt;

&lt;p&gt;(Hopefully I’ll start actually putting up stuff on this tumblelog again now…)&lt;/p&gt;</description><link>http://codemonky.com/post/99360011</link><guid>http://codemonky.com/post/99360011</guid><pubDate>Thu, 23 Apr 2009 14:12:49 -0400</pubDate></item><item><title>Orkut.com.br needs to die!</title><description>&lt;p&gt;Yes, I’m just one of the many who have fallen into the stupid Brazilian Orkut fake kid pages. There is a whole profile based off images from my Flickr stream.
&lt;br/&gt;&lt;br/&gt;

&lt;a href="http://www.orkut.com/Main#Album.aspx?uid=6447389076309092886&amp;aid=1230630259"&gt;http://www.orkut.com/Main#Album.aspx?uid=6447389076309092886&amp;aid=1230630259&lt;/a&gt;
&lt;br/&gt;
&lt;a href="http://www.orkut.com/Main#Album.aspx?uid=499062161829329821&amp;aid=1"&gt;http://www.orkut.com/Main#Album.aspx?uid=499062161829329821&amp;aid=1&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;

I know I could toggle the “Friends &amp; Family” setting on Flickr but I have too many people who look at my stream who are real friends and family that I don’t want to have to send a link or require them to sign up to see the pictures.
&lt;br/&gt;&lt;br/&gt;

Of course Google, the owner of Orkut.com, is of absolutely no help. Reporting abuse on the site gives me this wonderful canned response:


&lt;/p&gt;
&lt;blockquote&gt;
Thank you for your reporting of abuse on Orkut on “2009-01-06”. &lt;br/&gt;&lt;br/&gt;

Based on our review and consideration of Orkut’s terms of service, we understand that this content does not currently break any policies on Orkut. If you believe that a mistake has been made, please re-submit your complaint with additional information to help our support team better understand your concerns with this content.
&lt;/blockquote&gt;

Thanks Google. &lt;strong&gt;Thanks!!!!?!?!&lt;/strong&gt;
&lt;br/&gt;&lt;br/&gt;

Glad they are so willing to help fight their site turning into a steaming pile of crap with pedophiles, etc.
&lt;br/&gt;&lt;br/&gt;

Sigh, such is life on the interwebs.
&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;&lt;em&gt;Update:&lt;/em&gt;&lt;/strong&gt; a friend of a friend works at Google and was able to get at least one of the accounts nuked this morning.</description><link>http://codemonky.com/post/68724241</link><guid>http://codemonky.com/post/68724241</guid><pubDate>Tue, 06 Jan 2009 10:27:00 -0500</pubDate></item><item><title>Testing... Testing... This thing on?</title><description>&lt;p&gt;Well it looks pike I forgot about my tumblog for some time now. Guess it is time to resurrect it. &lt;/p&gt;

&lt;p&gt;Stay tunes for ramblings about languages I’m learning at the moment. &lt;/p&gt;

&lt;p&gt;First up…. Erlang.&lt;/p&gt;</description><link>http://codemonky.com/post/59753977</link><guid>http://codemonky.com/post/59753977</guid><pubDate>Fri, 14 Nov 2008 20:46:43 -0500</pubDate></item><item><title>Google does Atlanta</title><description>&lt;img src="http://30.media.tumblr.com/LdzHTkOYNagm53fyLP1PFryP_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Google does Atlanta&lt;/p&gt;</description><link>http://codemonky.com/post/39185058</link><guid>http://codemonky.com/post/39185058</guid><pubDate>Fri, 20 Jun 2008 13:36:39 -0400</pubDate></item><item><title>Endless Pages</title><description>&lt;p&gt;Having heard a blurb on an endless page plugin on the &lt;a href="http://railsenvy.com"&gt;RailsEnvy&lt;/a&gt; podcast, I decided to check it out. I wasn’t happy with how the plugin worked, so I whipped up something similar.&lt;/p&gt;
&lt;p&gt;(Original post mentioned on RailsEnvy: &lt;a href="http://bewhite.blogspot.com/2008/05/rails-endless-page-plugin.html"&gt;link&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;I decided most of what was needed was a mix of the wonderful will_paginate plugin and some Javascript. Thus &lt;b&gt;endlesspage.js&lt;/b&gt; was born.&lt;/p&gt;
&lt;p&gt;After including endlesspage.js in your layout, you should be able to do follow along below on how to set it up.&lt;/p&gt;
&lt;p&gt;In the &lt;strong&gt;Controller&lt;/strong&gt;: &lt;a href="http://pastie.org/197801"&gt;pastie&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the &lt;strong&gt;Views&lt;/strong&gt;: &lt;a href="http://pastie.org/197803"&gt;pastie&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is the file: &lt;a href="http://pastie.org/197806"&gt;endlesspage.js&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;(Sorry, but I couldn’t get Tumblr to cooperate with dumping in code.) &lt;/p&gt;
&lt;p&gt;Let me know if you find this helpful… &lt;/p&gt; 
&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; I was informed (and confirmed myself) that the gem version of will_paginate doesn’t have the page_count method. The substitute method is total_pages.&lt;/p&gt;</description><link>http://codemonky.com/post/34940898</link><guid>http://codemonky.com/post/34940898</guid><pubDate>Thu, 15 May 2008 16:19:00 -0400</pubDate></item><item><title>Video</title><description>&lt;object width="400" height="336"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Tbxq0IDqD04&amp;rel=0&amp;egm=0&amp;showinfo=0&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/Tbxq0IDqD04&amp;rel=0&amp;egm=0&amp;showinfo=0&amp;fs=1" type="application/x-shockwave-flash" width="400" height="336" allowFullScreen="true" wmode="transparent"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br/&gt;&lt;br/&gt;</description><link>http://codemonky.com/post/32181874</link><guid>http://codemonky.com/post/32181874</guid><pubDate>Fri, 18 Apr 2008 16:28:49 -0400</pubDate></item><item><title>silencing deprecations</title><description>&lt;p&gt;OK, so if you’re stuck in Rails 1.2.X land like I am, you’re probably tired of seeing all the deprecation warnings when you run your test suite. (Yes, I know pagination is going away but someone might severly punish me for will_paginate at the moment.)&lt;/p&gt;
&lt;p&gt; Add this to your test/test_helper.rb&lt;/p&gt;
&lt;pre&gt; &lt;p&gt; ActiveSupport::Deprecation.silenced= true &lt;br/&gt;&lt;/p&gt;&lt;/pre&gt; </description><link>http://codemonky.com/post/31491014</link><guid>http://codemonky.com/post/31491014</guid><pubDate>Fri, 11 Apr 2008 14:34:57 -0400</pubDate></item><item><title>Git on OSX</title><description>&lt;p&gt;Hit a roadblock compiling git tonight. Thanks to jnewland for the last piece of the puzzle.&lt;/p&gt; &lt;pre&gt;curl -O &lt;a href="http://kernel.org/pub/software/scm/git/git-1.5.4.5.tar.bz2"&gt;http://kernel.org/pub/software/scm/git/git-1.5.4.5.tar.bz2&lt;/a&gt; &lt;br/&gt;tar ixf git-1.5.4.5.tar.bz2 &lt;br/&gt;cd git-1.5.4.5 &lt;br/&gt;./configure --prefix=/usr/local &lt;br/&gt;make NO_MSGFMT=1 &lt;br/&gt;sudo make install  &lt;/pre&gt;</description><link>http://codemonky.com/post/31414966</link><guid>http://codemonky.com/post/31414966</guid><pubDate>Thu, 10 Apr 2008 23:00:24 -0400</pubDate></item><item><title>Apple goodness</title><description>&lt;img src="http://26.media.tumblr.com/LdzHTkOYN7bnicyuiZxTBGyA_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Apple goodness&lt;/p&gt;</description><link>http://codemonky.com/post/30581804</link><guid>http://codemonky.com/post/30581804</guid><pubDate>Wed, 02 Apr 2008 12:20:17 -0400</pubDate></item><item><title>establish_connection may harm you</title><description>&lt;p&gt;So I have a reporting Rails application that is looking at the databases of two other Rails apps. I import the models using an svn:external link. I then have initializers that do a bit of “magic” switching which databases the models use and what their table names are based on the schema. We use Postgres so the “databases” are actually schemas in the same physical database.&lt;/p&gt; &lt;code&gt;&lt;/code&gt;&lt;pre&gt;unless RAILS_ENV.downcase == 'test'&lt;br/&gt;  # point all of the vanguard models to the champion_#{RAILS_ENV} database&lt;br/&gt;  Dir[File.expand_path('app/models/vanguard/*.rb',RAILS_ROOT)].each do |file|&lt;br/&gt;    model_str = $1.classify if file =~ /\/vanguard\/(.*?)\.rb$/&lt;br/&gt;&lt;br/&gt;    next unless model_str&lt;br/&gt;    # skip the models that aren't active record models&lt;br/&gt;    next if %w(...).include?(model_str)&lt;br/&gt;&lt;br/&gt;    eval("#{model_str}.instance_eval('establish_connection \"champion_#{RAILS_ENV}\"')")&lt;br/&gt;    table_name = eval("#{model_str}.table_name")&lt;br/&gt;    eval("#{model_str}.instance_eval('set_table_name \"vanguard.#{table_name}\"')") &lt;br/&gt;  end&lt;br/&gt;end &lt;/pre&gt; &lt;p&gt;I kept running into a problem where the maximum number of connections to this database was being exceeded. After poking around some I believe establish_connection isn’t doing the smart thing. It seems to blindly establish a connection each time it is called disregarding the fact that the connection might already be open.&lt;/p&gt;
&lt;p&gt; I switched the logic such that the “primary” database is now this external connection and sub-class all of my internal models to use an abstract ActiveRecord class that points to a different database. The number of connections has dropped significantly. &lt;/p&gt;</description><link>http://codemonky.com/post/29190425</link><guid>http://codemonky.com/post/29190425</guid><pubDate>Tue, 18 Mar 2008 10:46:00 -0400</pubDate></item></channel></rss>
