Hidden counter in partial collections

February 4th, 2008 by Jo Potts 1 comment »

A quick tech post to share knowledge:

If you need a counter, iterator, index, loop variable number type thing inside a partial rendering a collection then you can simply use an undocumented counter called [partialname]_counter.

render :partial => 'parrot', :collection => @parrots

Then in _parrot.html.erb you can use:

parrot_counter

I like this like I like each_with_index. :)

Rails2 foot note: I think the :collection option can be dropped in my example with the names I’ve used here but I’ve left it in for clarity.

Mpeg1 muxed hell

January 3rd, 2008 by Jo Potts 2 comments »

How to convert muxed mpeg1 videos to something/anything(!) better… the demuxxing is the key step. I had to find this out for a site I made – laurechan.com

This is simply a cut and paste from my own notes. Hope it can help someone:

  • Start with the .mpg (mpeg1 muxed – audio and video combined)
  • Make MP2 – Use the free program ffmpegX (for the Mac) to demux into .m1v (video) and .mp2 (audio). Simply click the ‘demux’ button. the plugins aren’t required. You don’t need m1v so bin it. If anyone knows of a Windows equivalent then feel free to post a comment.
  • Make MP4 – Export the original .mpg as mpeg-4 (includes video only) using Quicktime Pro – my settings were: MP4, H. 264, 256kbits/s, 400×300 preserve letterbox, frame current, key auto.
  • Make M4A – Open the mp2 in iTunes and convert to AAC (right click). Find file and copy.
  • Make MOV – Open .mp4 in Quicktime Pro. Select all. Open .m4a in Quicktime, select and copy all. ‘Add to Selection & Scale’ into .mp4 . Save mp4 to make the .mov
  • Make FLV – Export .mov to .flv changing max video rate to 256kbit/s

Note: This uses Quicktime Pro which is not free. (Although I think it should be!)

Bug for the day

September 25th, 2007 by Jo Potts 1 comment »

If you’ve got a date_select in a partial on a collection and the date in the AR object isn’t being rendered by the date helper (and it defaults to Time.now) then the fix is to pass an :object parameter to the date_select holding the AR object (which is the partial’s local in my case). Got that?

eg

<%= render :partial => 'duck', :collection => @list_of_ducks %>

<%= date_select("duck"+duck.ref, "dob", :object => duck) %>

This one had me trawling the rails source on my hands and knees!