veader, the codemonky

ramblings, musing and code snippets
Jun 24
Permalink

Animated GIFs and UIImageViews

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.

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.

Then the Google hunt began…

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.

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.

Now for the code sample.

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];

There are a few other things you can play with like the animatedDuration and animatedRepeatCount properties. But you can figure those out.

And a link to the UIImageView documentation for completeness… UIImageView

Jun 16
Permalink

Must haves for Safari

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.


Click-to-Flash

http://github.com/rentzsch/clicktoflash/tree/master

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?)


AdBlock

http://burgersoftware.com/en/safariadblock

Recent addition for me but blocks ad content for a more pleasant browsing experience.

Apr 23
Permalink

Starting down the path of objectifying C

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.

My biggest gotchas/gripes I’ve found so far?

1) Having to add a nil to the end of a declared NSArray or NSDictionary (or their mutable variants).

[NSArray arrayWithObjects:@"1", @"2", @"3", nil];

That just seems like something that could be abstracted away for you…

2) Declaring a NSDictionary with keys and values is backward from what I would expect from Ruby land.

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

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 @.

(Hopefully I’ll start actually putting up stuff on this tumblelog again now…)

Jan 06
Permalink

Orkut.com.br needs to die!

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.

http://www.orkut.com/Main#Album.aspx?uid=6447389076309092886&aid=1230630259
http://www.orkut.com/Main#Album.aspx?uid=499062161829329821&aid=1

I know I could toggle the “Friends & 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.

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

Thank you for your reporting of abuse on Orkut on “2009-01-06”.

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.
Thanks Google. Thanks!!!!?!?!

Glad they are so willing to help fight their site turning into a steaming pile of crap with pedophiles, etc.

Sigh, such is life on the interwebs.

Update: a friend of a friend works at Google and was able to get at least one of the accounts nuked this morning.
Nov 14
Permalink

Testing... Testing... This thing on?

Well it looks pike I forgot about my tumblog for some time now. Guess it is time to resurrect it.

Stay tunes for ramblings about languages I’m learning at the moment.

First up…. Erlang.

Jun 20
Permalink
Google does Atlanta
Google does Atlanta
May 15
Permalink

Endless Pages

Having heard a blurb on an endless page plugin on the RailsEnvy podcast, I decided to check it out. I wasn’t happy with how the plugin worked, so I whipped up something similar.

(Original post mentioned on RailsEnvy: link)

I decided most of what was needed was a mix of the wonderful will_paginate plugin and some Javascript. Thus endlesspage.js was born.

After including endlesspage.js in your layout, you should be able to do follow along below on how to set it up.

In the Controller: pastie

In the Views: pastie

Here is the file: endlesspage.js

(Sorry, but I couldn’t get Tumblr to cooperate with dumping in code.)

Let me know if you find this helpful…

UPDATE: 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.

Apr 18
Permalink
Apr 11
Permalink

silencing deprecations

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.)

 Add this to your test/test_helper.rb

 

 ActiveSupport::Deprecation.silenced= true

 
Apr 10
Permalink

Git on OSX

Hit a roadblock compiling git tonight. Thanks to jnewland for the last piece of the puzzle.

curl -O http://kernel.org/pub/software/scm/git/git-1.5.4.5.tar.bz2 
tar ixf git-1.5.4.5.tar.bz2
cd git-1.5.4.5
./configure --prefix=/usr/local
make NO_MSGFMT=1
sudo make install