AnalogClock






Showing posts with label fix. Show all posts
Showing posts with label fix. Show all posts

Thursday, October 30, 2008

Yikes backslash zero on wordpress.com

I started a new blog at wordpress.com, One Liner Code. I was reviewing my posts when I realized that my sed example didn't make sense to me. I didn't understand how I could have messed up such a simple example in the language that most easily lends itself to one liners. I thought I had double checked all of my examples and made sure they were running right. Turns out the html code looked fine. There was a preprocessor stepping in between me and my sed Hello World post. It was turning my backslash zero into a null.

I whipped out my handy dandy php evaluator and encountered failure using the htmlentities() string function. php wouldn't give me the htmlentity code for characters that didn't need them. I decided to switch it up and get the charactor code using a ruby one liner:

ruby -e '"0".each_byte {|i| p i}'

I could have also used a php one liner like this:

php -r 'echo ord("0")."\n";'

The quick fix \0 allowed the post preprocessor to accept the backslash zero and turn it into the correct character representation.

Friday, March 7, 2008

Rails Requires RubyGems >= 0.9.4 Error on Mac OS X

Updated 2008-10-08:
Please note that I forgot to mention in this post the fact that Ruby on Rails is installed by default with OS X Leopard. This blog is most helpful to those who had previously installed rails using MacPorts and now want to move to the Apple supported version that comes with OS X Leopard.

I was following along with the Apple Developer Connection article that shows how to update and use the version of Ruby on Rails that comes with Mac OS X Leopard. I followed through the article without a hitch. Successfully creating the Events Rails Site and viewing it at localhost:3000. The only change I made outside of the article's instructions was to add the script/generate and script/console commands to the same place as the article recommends the script/server. I figured keeping the original data model definition commands with the rails project would help if I wanted to make any changes to the data model later. I moved the data model definition commands to a shell script located in the top directory of the project. Which will make a nice portable design convention. I have seen that method mentioned in a blog post before.

While I was browsing around the running instance of the Events rails site I decided to do a full update of all the gem packages on my system by way of "gem update" without the "--system". Big mistake or so I thought when I tried to start my own rails project a day later. I couldn't even get the generate commands to run. The response from every script/ command was the same "Rails requires RubyGems >= 0.9.4. I googled around for the solution which always seemed to say remove the Leopard version and install the MacPorts version. Which I didn't want to do since I was trying to get rid of the duplicate MacPorts packages in the first place. In fact I had thought I had removed all the ruby packages from MacPorts. But on reinspection I found 4 versions of Ruby installed and one active a la "port search ruby and installed". First I did a "port uninstall ruby and inactive" to get rid of the old versions. Then I found a ruby gem I had somehow missed when I had done a "port uninstall rb-* and installed". After removing the lone gem I got rid of the installed and active version of Ruby via "port uninstall ruby". A quick verification of /opt/local/bin verfied that there was no longer a ruby or gem or update_rubygems command left.

Of course I left out the part where I removed all of the manually installed gems under /opt/local/lib/ruby/1.8/rubygems by "rm -fr / opt/local/lib/ruby/1.8/rubygems". Don't quote me on that path as I am writing this post on my iPhone and recalling it from memory. I only know the path because I also reinstalled rubygems manually before I figured out what the real problem was. I would probably have missed the real problem if I hadn't installed rubygems with "ruby setup.rb" after downloading it. The install commands showed RubyGems beings installed to /opt/local/... I had to remove that copy of RubyGems manually. Which wasn't so hard. All the install commands with the full paths of the installed files were still in my scrollback buffer.

I also didn't mention that I had uninstalled all my gem packages from the Leopard side of things. Including the original packages under /System. Luckily one of the articles I'd googled had the complete list. It was easy enough to do a "gem install rails sqlite-ruby capistrano mongrel libxml-ruby ruby-openid ruby-yadis rubynode RedCloth sources ferret acts_as_ferret fcgi termios cgi_multipart_eof_fix daemons dnssd gem_plugin hpricot needle actionwebservice activesupport". The full list of preinstalled gem packages is available here. I abbreviated my gem install command to only include what is necessary as installing rails pulls in some of the other packages in the list like activerecord and rake.
Everything worked like a charm after that. Now on to writing that SFA app. After that I'll have to get back to my holy war to remove redundant MacPorts packages. I think I was up to removing those two verions of Python 2.4 and 2.5. Seeing as how Leopard ships with 2.5 and 2.4 was a buggy beast at best when compared to the speed and bug fixes of version 2.5.

Monday, February 18, 2008

Fix for iPhone not syncing some video

I use the iPhone. Before upgrading iTunes and the iPhone firmware I was able to load video on the iPhone using iTunes. Now I have problems getting the same video to sync to the iPhone. I also have problems getting some video podcasts to sync to the iPhone that used to sync just fine.

I did some research using ffmpeg -i on some of the files that synced and some of the ones that wouldn't sync. I found that the video that wouldn't sync all had something in common. The aspect ratio was showing up as 0:1 (for DAR and PAR).

I googled some iPhone video conversion parameters and found an ffmpeg parameter that gets any video to sync, -aspect 16:9. Now I just need to come up with a set of ffmpeg video conversion parameters that play for more than a few seconds before the audio drops out and the video stops playing.

Gonna try doing an ffmpeg copy and report back the results.

Update 2008-03-08

I found out a lot. The 0.49 version of ffmpeg that comes with ffmpegX works fine. It was either patched to deal with the QuickTime mpeg4 issues or uses default setting that work with QuickTime. Turns out QuickTime needs square pixels for mpeg4 and the harddup video filter to avoid a frame copy problem when it converts to the mpeg4 format as the duplicate frame flag gets lost in the translation. I haven't figured out how to do this with ffmpeg. But all the info on this issue is dealt with in a section of the mencorder documentation under the heading QuickTime. Mencoder uses ffmpeg under the "-lavc" flag.

I'll update with the details after I perform some tests.