Giantmike's Open Source Program Storage: Downloads

Navigation: Downloads - Links - Code Snippets

Looking for Open Source Objective C, C++, Java, Perl, etc. programs that are open source (sample code)? Look no further. These programs are free to use, and are truly meant to be used as learning tools. There are no license restrictions, so use any or all of the code in your own projects. Just keep in mind, I am not responsible for anything that happens if you use my code in your projects.

All files are zipped using the build in zipping functionality of Mac OS X. The programs have been tested to work on OS X, and in some cases Windows and Linux.

Objective-C/Cocoa (Xcode)
FavBrowse (140 KB) - Ever notice how the only way to pick your default browser in OS X is by using Safari's preferences? Well, that's all changed with FavBrowse. This program builds a list of possible browsers, and allows you to choose your favorite browser from a popup menu. The menu is build by querying the Launch Services database to get application bundle identifiers. It then retrieves the names for those programs, and using the programs, gets each of their icons. Upon selecting a choice, it writes the new option back to the Launch Services. Uses a mixture of Cocoa and Carbon including casting of data types between the two APIs. (Requires OS X 10.4+).

Notification Sniffer (112 KB) - Extending upon the Notification bundle, this application provides a way to find all distributed notifications being sent on your machine. But don't let the name fool you, many different examples are featured in this program. Among them: a window that can float on top of all others or behave normally; a text view that can have a user set background color, text color, transparency level, and font; the ability to save the contents of the text view to a file using the standard save dialog box, the ability o print the contents of the text view with custom page setup settings and correct pagination, and saving/getting all user settings to/from the application's preference file.

Notification Bundle (154 KB) - This download contains two separate apps. The first application sends a message using NSDistributedNotifications to other programs running on the same computer. The second program receives messages sent by others, and displays some fun text (in a random color) if the correct message is sent. Of course, the second application is only looking for messages sent by the first application. This type of inter-process communication is invaluable. Common uses are background apps (such as iCalAlarmScheduler) or extending applications created by others. You'll be amazed at how simple this type of communication is with Cocoa.

iChat Idle (137KB) - Ever notice how iChat sets your away message to "Away" if you have been idle for a set amount of time (around 30 minutes)? That wouldn't be so bad if it could be easily changed. Unfortunately, there is no current GUI controls to personalize this string. Thus, I created iChat Idle to do just that. This program features simple user input, sheet based alert dialogs, file input/output, checking for iChat running/quit via an AppleScript, and dynamic maximum window width based on screen resolution.
Update: New in version 1.1, now multithreaded based on how many CPUs/cores you have in your computer. If you only have a single CPU, only one thread will be spawned. If you have 2 quad core CPUs, then 8 threads will be created. To get this to function correctly, the main thread has to know when the auxiliary threads are complete. This involves conditional locks which can be tricky to understand. The code is well commented, so you should be able to determine how conditional locks work fairly easily.
Update: New in version 1.2, The program now responds to when monitors are hot-plugged, or a screen resolution is changed. In the case of the latter, the max window width is simply recalculated. In the former case, if the number of attached monitors decreases, the window resets itself to be positioned on the main display.

FoxTrotDownload (38KB) - I was annoyed at the pop under at the Ucomics web site when viewing my favorite comic strip, FoxTrot. To get around that annoyance, I created this program which takes the current date, makes a URL of the image from that date, downloads the comic strip, and displays it in the window. All of this is incredibly simple with the WebKit framework (included with Safari). It will even change the size of the window depending on the size of the comic (Sunday versions are larger than the rest).
Update: New in version 1.1, the Print menu item now prints just the comic (not the application window) in landscape view.

Swap Sizes (64 KB) - This program calculates how many virtual memory swap files are currently on your hard drive, and how much space they use up. Those two calculations are done in separate threads to illustrate multithreading. Also, a help file in included with instructions on setting up the help in XCode. Finally, Instructions are provided to enable a custom icon.
Update: New in version 1.2, now a Universal binary. Uses unsigned ints and a different location of calculating size in MB to avoid negative swap totals.
Update: New in version 1.1, more string functions used for optimizations, will ignore the sleepimage found on some laptops that artificially increased both output numbers, and better formatted output.

SimplePi (316 KB) - This program was basically made to play with Shark (one of the CHUD tools, used for optimization). All it does it calculate Pi a couple thousand times. Things to note for Shark (using Get Info on simplePi): Do NOT strip debug symbols, DO generate profiling code, DO generate debug symbols, and set the level of debug symbols to full.
Note: You may need to delete the 'build' folder before compiling if you see build errors.

Tip: If Xcode complains that there is no executable at the current path when trying to Build and Go, try the following:
  1. Use the Projects menu -> Set Active Build Configuration to select a different configuration than the one currently selected.
  2. Build using this configuration.
  3. Switch back to the original configuration.
  4. Build using the original configuration. You should now be able to Build and Go without errors.
C
test_malloc (1 KB) - I wrote this little program when I was helping someone with their program. They were trying to use very large arrays, but this caused segmentation faults when run. To avoid this, memory allocation was required, so the arrays can go to the heap instead of the stack.
C++
Print method timer (2 KB) - A command line based program that measures and compares the speed of printing out the same strings using printf and cout. The timing method can also be adapted to other programs, to benchmark routines.

windchill (1 KB) - A command line based program that calculates wind chills. Very simple user input and output included.
Perl
Maintenance Script Dates (92 KB) - I created a Perl script to parse the output logs from OS X's Daily, Weekly, and Monthly maintenance scripts. It looks for the last date the scripts were run, and reports it. However, I didn't stop there. I decided it need a GUI, so I used AppleScript Studio (part of XCode) to create a very simple interface which run the Perl script, and outputs it to a normal OS X window. Very cool! Note: this is a Universal Application so it runs natively on PPC and Intel Macs (requires Mac OS X 10.4.x or later).

perl_fun (3 KB) - My introduction to Perl, which has three different Perl Scripts. 1: Simple user input and output. 2: Using arrays. 3: Conditionals and loops.
Java
FunJavaStuff (4 KB) - This program was written to try out a bunch of different java functions. Among them are multiple windows, random numbers, dialog boxes, reading files, menu bars/items, and more.
Dashboard Widgets (HTML/CSS/Javascript)
Mad Town Radar (32 KB) - I was annoyed with a radar widget I had been using, so I decided to make this as a replacement. It's very simple, in that it only has a single HTML file. Mad Town Radar grabs the radar image from weatherunderground.com, so if you want to show a different image, just change the URL of the image. This is a good widget if you want to see how you can make something really basic in only about 15 minutes.

Maintidget (107 KB) - The Dashboard version of Maintenance Scripts Dates. It will display when the maintenance scripts were last run, and allow you to run the scripts on demand. To my knowledge, this is the first ever widget to allow for running the maintenance scripts (released on March 08, 2006). I commented up the javascript fairly well, so you should be able to figure out how this was accomplished.
All programs and code snippets available here are provided without warranty. They have not been thoroughly tested, and are not often updated for future OS compatibility (created only with the current version of Mac OS X in mind). You are hear-by authorized to use any part of these programs or source code for any personal or commercial use. I don't attach any kind of licensing to them, thus you are free to use them however you see fit. Your code does not need to be open source, and you don't have to include any indications of where this code came from in your software.
Site design and original content ©1998-2008 by Mike Vande Ven Jr.

Mac, the Mac logo, Mac OS, the Apple logo, and other Apple product names are trademarks of Apple, Inc., registered in the U.S. and other countries. The Made on a Mac Badge is a trademark of Apple, Inc., used with permission.

Additional company names, company logos, product names, and product images may be trademarks or registered trademarks and are hereby acknowledged.

Arbitrary Quote - I finally came up with a punishment for the boy. First, no leaving the house, not even for school. Second, no egg nog. In fact, no nog period! And third, absolutely no stealing for three months!