Gmail Mobile on the Motorola i776 for Boost Mobile

Posted on 2009.07.05 by Tony G.

Boost Mobile users with the Motorola i776 get a ‘phone not suported’ error when trying to install the Gmail Mobile app. Here’s a workaround to get you set up with Gmail Mobile 1.5.

Download and save this zip file: gm15.zip
Follow the instructions at this website.

After you get it installed and running, setup one of your hotkeys to point to Gmail by going to Settings/Personalize. This way you don’t have to run it from the Java Apps screen. This package may also work on some of the other Motorola iden phones…if so post a comment!

There is also Gmail Mobile 2.0, and though it will install on the i776, it will not run.
Download link for Gmail 2.0 jar: http://gmail.com/app/v2.0.6/L1/gmail-g.jar

Parsing out links from the Twitter API Response with Regular Expressions

Posted on 2009.04.30 by Tom

Recently while building AVLTweetup.com we decided that instead of just displaying the tweets as plain text and making people copy and paste links or hashtags into their address bar that we would just make them automatically link for them. It isn’t much work for us to do that and it saves people who use the site some time. This is pretty easily done using some regular expressions and replacing the pattern with a string we specify. Since Twitter has a well define format all we need to do is look for a few things and switch em out. Here is how we are handling each Tweet as we parse our tree of tweets.

	$formatted_text = preg_replace('/(\b(www\.|http\:\/\/)\S+\b)/', "<a target='_blank' href='$1'>$1</a>", $tweet-&gt;text);
	$formatted_text = preg_replace('/\#(\w+)/', "<a target='_blank' href='http://search.twitter.com/search?q=$1'>#$1</a>", $formatted_text);
	$formatted_text = preg_replace('/\@(\w+)/', "<a target='_blank' href='http://twitter.com/$1'>@$1</a>", $formatted_text);

So this will first replace any links with an actual anchor tag and then we are going to convert all our hash tags to links to searches and all our user tags to links to their page.

Now we have the formatted text from the raw text the Twitter Search API gives us. All we have to do is display it how we want in our layout. Also while printing out the content i made sure to enclose our text in a specified class so it would be easy to find it for the next little bit of code that will go and fetch any twitpics and display them when a user mouses over the url. I will do a full write up on that in the future so that I can walk through the whole process since it will involve css combined with js and some php.

A short post but it has been a while since a fresh post so starting off a bit slow!

Flourish, the Newest Addition to Your Toolbox

Posted on 2009.03.03 by Tom

Developer’s Toolbox

If you are like me you have what I like to call “A Development Toolbox.” It is basically a collection of tools that I will choose from when developing a site for a customer. In my toolbox I have a couple of frameworks I like, MVC of course, a CMS option, three to four carts I can choose from depending on the size of the clients business and their requirements, and the trusty JQuery. The thing that has been bothering me for a while is that I have a hole in my toolbox.

Toolbox Problems

The whole purpose of this toolbox is to increase my development speed, decrease my overhead, and get the client’s site turned out as quickly, securely, and functional as possible. So if I need a simple three or five page static site I don’t need the server overhead of any of my current tools. I only need some static XHTML and CSS, maybe some simple JS for looks. So that is well and good, I keep a tar file that I can unpack and have a good base layout and file structure so I can start working.

Where I get slowed down is when it comes to maybe needing to do a little database work, or to handle some form errors in a quick, friendly way. I have built classes in the past to handle these things, to help me work faster but I always go back and redo and redo to try to make it work more efficiently. So I end up spending a lot of time on trying to make my code better when I use them. So what is the point in all this long, drawn out intro? I am trying to set up why Flourish might be the next big tool to add to your toolbox.

What is Flourish?

Flourish is a PHP Library, make sure to read that right, it is not a framework. It is a collection of classes that can help you build projects without having to start from scratch. I know that you are probably thinking, “that sounds a lot like a framework!” Well you are right it does “sound” a lot like a framework but it isn’t. The difference is that there are no set ways of having to organize your files first of all and most importantly you are not required to include Flourish if you don’t need it on that page. So maybe you don’t have any use for Flourish on your Home Page, About Page, or FAQ Page but you do need it on the Contact page then that is ok. You can just use it there.

I think what I will be using it for will be not only to just help out on pages where I want to use the libraries but also to handle a lot of my layouts. The layout system is almost exactly what I use normally but this will help me to keep it standardized since it works very similar to how I usually work but it keeps me using the same system instead of changing code around as I might have an urge to sometimes do.

Notes on Flourish

Flourish seems to be new, but that is a good thing sometimes. I have written before that when picking a framework that you need to find established frameworks with good communities. Well with a library like this I think that coming in soon is a great idea. Here is why. If something is not easy to figure out you can get into the code and figure it out whereas a framework often time has so much overhead code that it is hard to read class docs and get to the skinny. Another reason is that I think Flourish has a good opportunity to have a great online community eventually. Once there are some awesome people using it who like to help others there will be a chance of an IRC channel or a active forum and lots of blog posts to help you out a long the path.

So from someone that really likes MVC, and pretty much has spent all their real dev time using it, why would I suggest this over the framework. You can do these same things with a framework and on a mostly static site you can get away easy by using CakePHP with their pages controller that comes with the stock distro. The speed wouldn’t suffer very much if any and you would be saving the same amount of time. Using a Drupal you can set up the same site and do what you need super duper fast and be ready to launch and if the client ever wants admin control you can just add it in by giving them a role and a password. So what is the point in using something lighter, less supported, and not as popular?

Change

I think that some kind of change is coming, I think that people are finally starting to realize that they don’t have to go with the trends, MVC while it has it’s obvious strengths is not always necessary and using it where it is not benefiting you and the client is just being a fan boy. I hate to be so harsh but I guarantee that if you ask even the developers of Flourish they will tell you that MVC has it’s place and that they use it when they need it and don’t when they have better options. Some people choose one particular tool and use it for everything but that means that they have made the wrong choice at least a small percentage of the time. For instance if you are a person who only uses Wordpress and don’t have the option of using anything else you will have seriously crippled yourself when it comes time to do some E-Commerce. It can be done, but it won’t be done as well as if you used Prestashop, Magento, etc… Back to my starting point though, these are all tools, sure you can get screws out of a piece of wood with a hammer but why not just use the screwdriver, or in the case of Flourish, the Black and Decker Super Duper Power Handheld Screwdriver.

Safari 4 Beta CSS Hacks

Posted on 2009.02.25 by Tom

It is innevitable that sooner or later you will have some display issue in Safari that you just can’t seem to fix without weirding out the other browsers. This, for me, is not very common at all but it does occasionally happen so previously with Safari 3 the way I commonly used to target Safari only was to do this.

	/*\*/
	html*div.focusdiv div#tcontent div.subdiv{
		position: relative;
		left: -3px;
	}
	/**/

Well in the newest Safari release, version 4, this doesn’t work anymore. So what if we need to target something now? Well luckily enough there is still a way to target Safari only and as an added bonus it actually looks a lot nicer than the current method.

  @media screen and (-webkit-min-device-pixel-ratio:0) {
    div.focusdiv  {
		width: 400px;
	}
    div.focusdiv div#tcontent div.subdiv {
		position: relative;
		left: -3px;
	}
  }

That is pretty much it, to provide credit to the authors, the first method was called the Stokely Hack and the second method is from this site.

FFMpeg and Converting Entire Folders of Files – Added Bonus Renaming All the Files you Converted

Posted on 2009.02.20 by Tom

Using FFMPEG to convert a whole folder of videos is actually a lot easier than you would think. Lets take a look at a really basic bash script to do so.

	#!/bin/bash
 
	DIR=/Users/tom/Desktop/Video
 
	for i in `find $DIR -type f`; do
	  ffmpeg  -i $i $i.mpg
	done

Thats it, just make sure to change the DIR variable to where you are working at, this could be made to take user input easily also or to just work in the current directory but that is up to you as to how you use it and change it. Here is a small change you can make that will make this script infinitely more useful.

	#!/bin/bash
 
	DIR=/Users/tom/Desktop/Video
 
	for i in `find $DIR -type f`; do
	  ffmpeg  -i $i $i.mpg
	  ffmpeg  -itsoffset -4  -i $i -vcodec mjpeg -vframes 1 -an -f rawvideo -s 200x200 $i.jpg
	done

Adding the next ffmpeg line makes you a nice thumbnail for your video that is 200×200, again you can modify to your needs easily.

Well now we have our files converted but since we didn’t work any magic in the bash script to convert them we have some ugly file names. For instance you may have before had the file video.avi and you converted it to an mpg so now we have video.avi.mpg. That won’t do so lets look at a really simple ruby script to parse the directory and rename our files how we want.

	#!/usr/bin/env ruby
 
	def get_input
	  system('clear')
	  puts "What directory will I be working in? ( \e[32mMust be absolute path\e[0m )"
	  directory = gets
	  directory.chomp!
	end
 
	def parse_directory(directory)
	  basedir = directory
	  file_stack = Array.new
	  Dir.new(basedir).entries.each do |file|
	    unless File.directory?(file)
	      file_stack.push file
	    end
	  end
	  return file_stack
	end
 
	def bulk_rename(file_stack)
	  file_stack.each do |file|
	    command = "mv #{file} "
	    file.gsub!('.avi.mpg','.mpg')
	    command &lt;&lt; file
	    system command
	    print '.'
	  end
	  print "\n"
	end
 
	file_stack = parse_directory(get_input)
 
	puts "I found \e[34m#{file_stack.nitems}\e[0m files"
 
	bulk_rename(file_stack)
 
	puts "Looks like I am done please type \e[31mls -l\e[0m to make sure I didn't mess up!\n"

This script is actually much shorter than it looks but it handles some basic user input so you can run this and let it know what directory to work in. I use this same script alot to rename a directory of files to other extentions or what ever. The line that has file.gsub!('.avi.mpg','.mpg') can be changes to any 'Pattern', 'Replacement' that you need. This script is not perfect by any means so use that at your own risk.