Header Image - charles newman's blog

Adobe Flex – Use working sets to manage your projects

by Charles Newman

If you have a lot of projects in Flex Builder you can use working sets to make them more manageable.

In the Flex Navigator view (this is the project tree), click on the toolbar menu and select “Select Working Set”. Click the “New…” button. Choose “Resource” and click “Next >”. Give your working set a name and then choose the projects that go in it.

This is a huge productivity boost, not only for working with projects, but also for searching across your source code. When you do a “find in files” (cmd+shift+F), you can select a working set to search in.

Perforce – get a report of all changes (p4 changes)

by Charles Newman

If your development team is good about providing detailed descriptions in the submit notes, such as bug tracking reference numbers, source files changed and why, etc., then you can use this Perforce command to easily create a report to hand to QA or whoever manages your release.

This command gets all changes made from a specified date to now for your client spec. The $P4CLIENT is an OS X environment variable, but could be left off (to see changes for all client specs) or specified as a string. The date format is year/month/day.

p4 changes -L -c $P4CLIENT @2009/05/11,@now

Or if you want to see everyones changes to a particular branch of the depot for a date range, here’s how you do that:

p4 changes -l //depot/my-awesome-code/my-project/...@2011/02/25,@now

And obviously you can pipe that into a text file to edit and possibly use in your release notes:

p4 changes -l //depot/my-awesome-code/my-project/...@2011/02/25,@now > p4-changes.txt

Mac OS X – Easy way to do a hex dump of a file

by Charles Newman

Occasionally, as a developer, I have a need to do a hex dump of a file to inspect extraneous tab characters, extra newlines, etc. On the Mac, you can easily do this on the command line.

With this command, you can get a nice, side-by-side hexadecimal and ascii view of the first 128 bytes of a file without downloading any shareware or other development tool:

hexdump -C -n128 myfile.ext

Google Picasa Web API – some photos will not load in IE and Safari

This baffled me for a few days.  I wrote a Flex app to try out Google’s Picasa Web API and it worked great in Firefox on a Mac.  But some of the images would not load in Safari (Mac or PC) and IE 7.  I eventually stumbled on a query string param that fixed it.

Apparently, some browsers limit the size of images to 800 pixels for the largest dimension.  If your images will not load in IE and Safari, try adding “imgmax=800” on the query string when you request an image, like this:

http://photos.googleapis.com/data/feed/api/user/yourusername/album/youralbum?kind=photo&imgmax=800

Mac OS X – Create an Alias by Clicking and Dragging

by Charles Newman

An “alias” in OS X is a symbolic link, or essentially a reference to another file. It is not a copy of the file, just a pointer to it. So for example, if you find yourself digging through folders in the Finder for the same document every day, it might be more efficient for you to place an alias of the file on your desktop.

To do that, simply drag it from the Finder window and hold down the Cmd (or Apple key) and the option key while you drag. Let go and you have your new alias.

You can also create an alias by selecting the file (single-click) and then typing Cmd l (that’s a lower case L). This will create an alias right next to the file it references. You can then drag the alias, or cut and paste it anywhere you like.

Mac OS X – Starting/Stopping Apache

by Charles Newman

Every Web developer needs to test files with a Web server and the most convenient way to do that is to run a Web server locally on your development machine and access it via localhost (127.0.0.1). One of the reasons Macs make such great dev machines for Web developers is they come standard with almost everything you need: Apache, MySql, Python, Perl, PHP, Java, etc.

From a Terminal window, these commands will start or stop Apache:

  • sudo apachectl start
  • sudo apachectl stop

After you’ve started Apache, browse to this address and you’ll see the standard Apache page:
http://localhost

The default location of the web site files on your file system is called the document root, and that is here:
/Library/WebServer/Documents

If you use this address:
http://localhost/~yourname

Those files are here:
/Users/yourname/Sites

Trouble shooting
If the default Apache page doesn’t load when you click http://localhost, check to make sure the Apache process loaded. You can type this into a terminal window to verify that Apache is loaded:

ps acx | grep -i 'httpd'

If you don’t see anything returned that means Apache failed to load. To find out why, run the Console app (you can find it in /Applications/Utilities or just type “console” into Spotlight). Click “All Messages” and you should see something like this:

httpd: Syntax error on line 117 of /private/etc/apache2/httpd.conf...

In that case just open the httpd.conf (you will probably need to “sudo vi httpd.conf”) and make adjustments. You may need to comment out some mods that are failing to load, or you need investigate what is wrong with the offending mod.

Mac OS X – Show Hidden Files in the Finder

by Charles Newman

The Finder, by default, does not show you every file on your system. You can tell it to show file extensions in the Preferences pane, but there is no preference for showing hidden files. Sometimes you want to edit your .bash_profile in something other than “vi” :)

Launch the Terminal app and:
1) Type this command in a Terminal window:
defaults write com.apple.finder AppleShowAllFiles TRUE
2) Restart Finder:
Option+Cmd Click the Finder Icon in the dock and select "Relaunch"

Mac OS X – Create a Zip File and Give it a Password

by Charles Newman

You can do this on the command line (in the Terminal Application) without any other software.

zip -r -e misc.zip ./misc

The command above takes the entire contents of the ./misc folder (-r means recursive) and creates misc.zip in the current directory.

to unzip:

unzip misc.zip (it will prompt you for the password)

To unzip from the Finder, you’ll need Stuffit Expander (currently there is a free download at http://www.stuffit-expander.com)