This is more a note to self than anything else, as there are many posts already on the internet about this.
Recently I’ve needed to get mail on the road, and my employer’s policy forbids to connect a non-standard device to their network. So, a GPRS connection through the phone is an OK alternative. Nothing as the 3G connection I used to have in the United Sates, but it is OK. My provider is China Telecom, but the instructions here work for any other provider.
- Pair the Treo and the Mac, if you haven’t already do so. The Bluetooth Setup Assistant should do everything required. Just follow the steps. Choose “Mobile Phone” as the type of device

- Check the services on the newly added device. When selected on the Bluetooth panel, the Dial-up networking service must be present

- Go back to see all the control panel modules, choose Network, and now you should have a Bluetooth connection (if it wasn’t already present). Add a new configuration for your service provider – handy if you travel a lot

- Now fill in the required login information. For China Telecom, account and password are guest, check this page if you don’t know the correct info for your phone provider. Bear in mind that data rates are expensive if you don’t have the appropriate plans.

- Click on Advanced. In my case, the Treo worked fine with the Generic script as shown below. If not, find out what works for your phone. For instance, for a RAZR V3xx I used in the US, Ross Barkman’s scripts worked well, as mentioned in a post some time ago.

- Finally test, try to connect.

Hope this post helps someone else. If you have other suggestions, please leave me a comment.
Tagged with: .
Yesterday I upgraded my Macs to Leopard. The main reasons for the upgrade were XCode 3.0, Time Machine and BootCamp. I had been using the latter very robustly on my machines. I read rumors a while ago about the BootCamp beta program ending for previous OS versions once Leopard was released, and I haven’t had the time to double-check.
Two features that have not received as much publicity but were very pleasant surprises (I know, I never Read The Fine Manual) were the inclusion of the A2DP profile in the Bluetooth stack, and TextEdit’s ability to read OpenOffice .odt files.
Nice touch. As usual with Apple, new functionality is rolled out in a seamless, intuitive and non-intrusive way.

Tagged with: .
Lifehacker posts this article about recovering lost pictures on memory cards. Mac OS X owners may want to try these two commands before purchasing additional software: dd and fsck. Linux users most likely already know what to do
— if not, the instructions below are 98% the same…
- Find the device id: Connect your camera using the USB cable, or mount the card in a reader. Then you can type on the console the command
mount, to see the mounted volumes. Look at the output for a line that contains /Volumes/name_of_your_card. On the same line, you will see a device identifier, something like /dev/s1d0. Take note of it, exactly. Then eject the card (you can drag it to the trash)
- Backup your card: The command makes a low level block copy of your card. Type
sudo dd if=/dev/the_id_you_wrote_down of=~/backup.hex
You’ll need to enter your password to run this command under sudo. It will create a file on your home directory with the card contents, so if you have a 1GB card, you’ll have a 1GB file, even if the card has no contents
- Attempt recovery: The proper step here is to attempt recovery on the image. It’s a bit more involved, as Mac OS usually doesn’t allow to mount a file as a loopback as Linux does. I’ve had success using the dangerous route of working directly on the card:
sudo fsck_msdos -p -f /dev/the_id_you_wrote_down
The problem with this is, it will modify your memory card contents, so further attempts to use recovery tools are more likely to fail.
Tagged with: .
This weekend I set up a backup wireless connection using my Bluetooth cell phone (Motorola RAZR v3xx). Pretty painless, thanks to Ross Barkman’s scripts, and Ed Thomson’s post.
More or less standard modem configuration. I had almost forgotten about such old good times when you had to deal with modem connection strings and those type of things.
Anyway, the process was:
- Downloaded the Motorola GPRS modem scripts from Ross Barkman’s page into /Library/Modem Scripts
- If you are trying to follow these instructions, but have not paired the phone already, you can do it now and the Bluetooth Setup Assistant will guide you through the steps. If you had already paired the phone, then from the Bluetooth menu item, you can choose “Open Bluetooth Preferences” to open the Bluetooth Setup Assistant. Here I was able to configure the phone.
- The specific settings I used:
- Account Name: ISP.CINGULAR, which should allow me to use the GPRS 128k/sec service, or ISPDA@CINGULARGPRS.COM
- Password: CINGULAR1
- Modem type: Motorola GPRS CID1 (will only appear with Ross’ scripts
My speed test was OK: 690-860 kbps downstream, and 220 kbps upstream with delays of up to 220 ms. Not a T3, but quite acceptable for occasions where I have no other net access
I’ve had a couple of issues using ISP.CINGULAR, where after 3 or 4 times of connecting fine, it stopped connecting. Last 2-3 times I’ve used ISPDA@CINGULARGPRS.COM it seems to work better, and with the speed described above
With both of the address, there is something causing the first connection attempt to fail. Perhaps I’ll look into it later – my current workaround is not that bad, just reconnecting after it fails once.
Tagged with: .
The guys at Strobist posted today a series of tips on how to get the most out of your webcam. Very interesting. One thing that still is puzzling me is why after I installed Windows XP on our 17 inch iMac with BootCamp 1.2, the quality of the webcam image on Windows is better than what I’m getting on MacOS!! Really strange.
The Windows drivers that come with BootCamp make a USB emulation of the built in iSight, and perhaps there is either some color correction done during the emulation, or what would be most ironic, that the color correction algorithms on MacOS are actually trying too hard to compensate and end up making the image worse.
That iMac’s setting is problematic for video conferencing because the iMac is in the opposite side to a window, and facing the wall. The back light coming through the window creates a dark webcam pic. If anyone has solved this problem, I’d love to know.
Tagged with: .
I’ve been recently working on some screencasts to demonstrate data analysis techniques.
Two common features I needed for my screencasts, which I’ve seen many screencasters also use/need, are:
- Overlay of a small frame on top of the screencast. For instance, you may want people to see you while you are talking. With computers taking more and more an active role on activities like interviewing, taking down patient records, etc., you may want to highlight some personal interaction tips while using your software. Perhaps you want to show a piece of hardware associated with the screencast. The limit is your imagination.
- Watermark your screencast You may want to prevent others from using your screencast on other sites without the proper credits.
 |
This image shows basically what I needed. By the way, it is actually created with my program. |
I started last weekend trying to do it with Quicktime Pro, and found it quite cumbersome. I can record the screen activity fine on the PC, as well as recording myself talking. Here the easy part ends. Then I have to add a video track on QT Pro, guess the offset entering it with numbers, and recompress. No, I wanted something simpler. Searching on the internet, found people using higher end applications, like Final Cut Pro. Not wanting to fork $1,299 for Final Cut Pro or $299 for Final Cut Express, I coded a simple app to achieve what I need. It works nicely, and with that many people doing screencast these days, I think there may be interest for it. When it’s completely finished, I’ll release it as a $9.99 download, and will set up a permanent page for it so people can purchase it. Meanwhile, I’d like to gather some feedback, so if you are a brave soul that can deal with beta software, and have use for the tool, please contact me. The first 25 beta testers will get a full version of the software when it is done. Sorry, no plans to open source the code so far.
(more…)
Tagged with: .
I had old scans of many guitar tab books as a directory of JPEG files, sequentially numbered. That was the way the old scanner stored documents. My SnapScan has an automatic document feeder and scans directly to PDF, which is much nicer to use. I wanted to join these JPEGs into a single PDF. After looking for different ways to do it, AppleScript, available software, etc., decided none of them were acceptable for my needs.
To accomplish the task, I used the following process (not optimal, but works):
cd directory
ls *.jpg | sort | xargs SavePDF
Where SavePDF is a program I hacked in an hour or so, using the CoreImage interfaces on the Mac. The code for SavePDF is shown below. Compile it with XCode, as of this writing Version 2.4.1
Precompiled binary for Mac OS X Intel platform is available here (in some browsers you’ll need to right-click and select “Save As…”)
Note that there is no error checking at all for the arguments. The resulting file is left at the current directory with the hardwired name “joined.pdf”
Use at your own risk – Works for me, YMMV. Other formats besides JPEG are supported by CoreImage and this code will work also with BMPs, PNGs and others. I personally have not used it for any other format.
(more…)
Tagged with: .
Although XCode has its own “code beautifier” built-in function (Format->Re-indent), it didn’t make it for me. It seems it is more tuned up for Objective C, but with a lot of my code being C++, these are among the biggest annoyances:
- The first line after private/public/protected were indented one more tab from what it should be

- Some of the Qt macros were also improperly indented
- It didn’t do anything to other elements of code beautification, like spaces between operators, breaking up complex statementes, etc.
So, I reverted to the trusted astyle which I use in Linux. The integration with the XCode IDE works well. Here’s what I did:
1) Installed astyle. Strange enough not Fink or Darwinports have it at this time available on their default trees. So I had to compile it from source and install it on /usr/local/bin
2) On ~/Library/Application Support/Apple/Developer Tools/Scripts/ created a new script with the code shown below. On my particular setup, I had previously copied the scripts from /Library/Application Support/Apple/Developer Tools/Scripts/ into my personal directory, so it has the default structure Apple uses. You may have a different organization. In my case, the script is under 10-User Scripts/40-Code/30-astyle.sh
#! /bin/sh
#
# astyle.sh - Reformats code using astyle
#
# -- PB User Script Info --
# %%%{PBXName=Reformat with astyle}%%%
# %%%{PBXInput=AllText}%%%
# %%%{PBXOutput=ReplaceAllText}%%%
# %%%{PBXKeyEquivalent=}%%%
echo -n "%%%{PBXSelection}%%%"
/usr/local/bin/astyle --style=kr -s4SKNap < &0 2>/dev/null
echo -n "%%%{PBXSelection}%%%"
3) Reloaded the script menus in XCode. All set!
The script is taking all the text of the front window when it is called, running it through astyle and replacing all the text with the result. The settings –style=kr -s4SKNap are my personal preferences. You may want something different. However, don’t forget the 2>/dev/null, otherwise the greeting messages that astyle sends to stderr will mix into your code.
astyle can read a .astylerc on your home directory, which perhaps is nicer than specifying the switches as I did, but I’m lazy.
Happy reformatting!
Tagged with: .
While developing the iPhoto add in I found these interesting sources for several Cocoa classes.
Tagged with: .
Following up on my previous hack, I ended up writing a plug in in Objective C. It’s currently loading, not much frills. I’m deciding if I’ll try to reuse my Python code bridging with PyObjC or just rewrite in Objective C the export. Most likely the latter.
Here is a screenshot. When installed, my plugin nicely adds another pane to the iPhoto export options. It will export to a folder, just like Apple’s Web export plugin. The users can upload the folder to the webserver however they like.

It borrows a lot of the UI from iTunes builtin web export (more than literally, because I copied a couple of things from the .nib). I hope to have time in the next couple of weeks to finish it. Looks promising, though.