Thursday, February 21st, 2008
Installing IPython, SciPy, and Matplotlib into Apple’s Python on upgraded Leopard
Start by reading this reference and some tips at MacResearch.
Because it obscures the nice Leopard python that includes Numpy and Dtrace, remove your old Python completely.
sudo rm -rf /Library/Frameworks/Python.framework/
Check that NumPy is already installed and working.
python
import numpy
numpy.test(1,10)
Install latest IPython, version 0.8.2. Note that I always alais untar='tar xvzf' in my bash setup.
wget http://ipython.scipy.org/dist/ipython-0.8.2.tar.gz
untar ipython-0.8.2.tar.gz
cd ipython-0.8.2
sudo python setup.py install
Install a fortran compiler binary because it is needed to compile/install Scipy. I get the PPC version of gfortran. You can also find the Intel version at HPC Mac OS X.
wget http://internap.dl.sourceforge.net/sourceforge/hpc/\
gfortran-ppc-leopard-bin.tar.gz
sudo tar -xvf gfortran-ppc-leopard-bin.tar.gz -C /
Edit a disttools file in Apple’s NumPy distribution so it is more lenient in allowing the use of the above gfortran compiler when building SciPy. Inspired by this note.
cd /System/Library/Frameworks/Python.framework/Versions/2.5/\
Extras/lib/python/numpy/distutils/fcompiler
sudo cp -p gnu.py gnu.py.bak
And edit the following lines as follows (I use mate gnu.py to edit in TextMate).
- version_match = simple_version_match(start=r'GNU Fortran (?!95)')
+ version_match = simple_version_match(start=r'GNU Fortran')
- version_match = simple_version_match(start='GNU Fortran 95')
+ version_match = simple_version_match(start='GNU Fortran')
Build and install SciPy 0.6.0. Source available here.
wget http://internap.dl.sourceforge.net/sourceforge/scipy/\
scipy-0.6.0.tar.gz
untar scipy-0.6.0.tar.gz
cd scipy-0.6.0
sudo python setup.py install
This installs SciPy here: /Library/Python/2.5/site-packages/scipy, which isn’t seen by Python at first. I added the following to my .profile.
export PYTHONPATH="/Library/Python/2.5/site-packages"
Test it after closing your terminal and re-opening. I actually have 2 failures and 3 errors, but they are things I don’t care about at the moment.
python
import scipy
scipy.test(1,10)
Install matplotlib binary.
wget http://internap.dl.sourceforge.net/sourceforge/matplotlib/\
matplotlib-0.91.2-py2.5-macosx-10.3-fat.egg
sudo easy_install -N matplotlib-0.91.2-py2.5-macosx-10.3-fat.egg
Test it out and be happy that you’re done!
ipython -pylab
plot([1,2,3])
/mac 〆
permanent link
Wednesday, October 17th, 2007
Clean up your Contextual Menus
Thanks to this TidBITS article, I was tipped off to find this Mac OS X Hint about how you can rebuild the Launch Services database that determines which applications show up in your “Open With” contextual menu. My Open With had a huge amount of cruft accumulated over time with Classic apps, apps on my backup hard drive, and an annoying number of image droplets in the Photoshop/Samples/Droplets folder.
So I rebuilt my Launch Services database to make my Open With much cleaner and faster. Here’s how I did it.
Eject my backup hard drive so that the database doesn’t include duplicate copies of all my applications.
Archive the Photoshop/Samples/Droplets/ folder (right click, Create Archive, then delete the folder).
Add the following line to my ~\.profile so typing the lsregister command is easier. (alias ... should all be on one line)
# make launch services register easy to find
alias lsregister='/System/Library/Frameworks/
ApplicationServices.framework/Frameworks/
LaunchServices.framework/Support/lsregister'
Save a description of the old database (out of curiosity, not necessary).
lsregister -dump | less > lsregDumpOld.txt
Rebuild the database. (all on one line)
lsregister -kill -r -f -domain system -domain system
-domain user "/Applications"
Save a description of the new database (again just curious).
lsregister -dump | less > lsregDumpNew2.txt
The new database is now about 1 MB, down from the original 6 MB. There sure was a lot of junk in there!
/mac 〆
permanent link
Saturday, October 13th, 2007
iPhone Unleashed
Hack the iPhone is the best site that collects iPhone hacks, how-to’s, and downloads. Installer.app is a package manager that lets you install, update, and uninstall a great variety of 3rd party iPhone software. Awesome. Finally, iFuntastic lets you change your icons, backgrounds, and install apps.
Update:
The iPhone Dev Wiki gives the most updated info on current hacking status, including a list of working native apps.
Also, iPhone Alley has some great news and guides.
Also also, iPhonegoboom has good warnings.
/mac 〆
permanent link
Monday, September 3rd, 2007
Read and Write NTFS on Mac
I was having trouble mounting, reading, or writing to an external USB hard drive on my Mac. Trouble was it is formatted with NTFS and I didn’t want to reformat. Solution: install macfuse and ntfs-3g then go to Terminal and type
diskutil list | grep Windows_NTFS
to find your NTFS disk matching /dev/disks, then mount the disk
mkdir /Volumes/ntfs
ntfs-3g /dev/disk3s1 /Volumes/ntfs -ovolname="Fuse Drive"
Also, if you’d like to graphically mount a SSH or FTP share as a drive, install MacFusion. Now I wish MacFusion worked with NTFS too …
/mac 〆
permanent link
Sunday, November 5th, 2006
Restarting TiVo Desktop Automagically Using Launchd and AppleScript
For some reason, TiVo Desktop version 1.9.3 (008) for Mac OS X is a processor hog for me. Especially after I’ve committed the crime of actually running iTunes or iPhoto on a given day.
I’ve noticed that stopping and starting TiVo Desktop improves this situation, but I’ve also gotten personally tired of doing this, so now I offer you a way of automating an escape from this monotony. Use the plist file here:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.dailyburrito.restartTiVoDesktop</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/restartTiVo.app</string>
</array>
<key>ServiceDescription</key>
<string>Restarts TiVo Desktop periodically.</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>18</integer>
</dict>
</dict>
</plist>
saved in the /Users/uname/Library/LaunchAgents/ folder with a name something like com.QuickSilverWatch.plist in combo with these launchd instructions. Or, just use lingon as described is this Mac OS X Hint. Either way, you’ll need this applescript to actually reboot TiVo Desktop:
-- open Sys Prefs and wait for it to open
tell application "System Preferences"
activate
end tell
-- stop/start TiVo Desktop w/10 trys
repeat 10 times
delay 1
try
tell application "System Events"
tell application process "System Preferences"
-- set frontmost to true w/10 trys
repeat 10 times
try
click menu item "TiVo Desktop" of menu ...
"View" of menu bar 1
delay 1
tell window "TiVo Desktop"
click button "Stop"
click button "Start"
end tell
exit repeat
end try
end repeat
end tell
end tell
exit repeat
end try
end repeat
-- quit Sys Prefs
tell application "System Preferences"
quit
end tell
You must have GUI Scripting enabled to run this AppleScript.
/mac 〆
permanent link
Sunday, April 23rd, 2006
Commands necessary to make squid run as a proxy for ME not as admin
Assumes squid installed via fink.
Useful for debugging:
squid -NCd1
top -l 1 | grep squid
sudo squid -k shutdown
Making squid have no cache — I just want it to be a proxy —
add the following to /etc/squid.conf:
acl AllIncomingIps src 0.0.0.0/0.0.0.0
no_cache deny AllIncomingIps
Getting the permissions right (make owner me and open up permissions):
sudo chown -R myusername /sw/var/log/squid/
chmod -R u=rwx,g=rw,o=rw /sw/var/log/squid/
sudo chown -R myusername /sw/var/cache/squid/
chmod -R u=rwx,g=rw,o=rw /sw/var/cache/squid/
sudo chown -R myusername /sw/var/run/
chmod -R u=rwx,g=rwx,o=rx /sw/var/run/
Now, I can run squid instead of sudo squid and that makes me happy.
Of course, I actually don’t run it manually, I use launchd thanks to Steve’s instructions.
/mac 〆
permanent link
Sunday, March 19th, 2006
GUI for real-time file usage info in Mac OS X
Robert Pointon has written the GUI analog to fs_usage in fseventer. It shows a very nice graphical display of all file system events.
/mac 〆
permanent link
Sunday, March 19th, 2006
Effect of Bandwidth Optimizer
I installed Broadband Optimizer, a program that aims to increase network speed on Mac OS X by increasing TCP memory buffers, effectively making data come in bigger chunks.
I used 3 online bandwidth testers to quantify the improvement (clearing Firefox’s cache between each test). I took the best of three runs of each test.
c|net test
1350 -> 1586 kbps (17% increase)
bandwidth speed test
2300 -> 2500 kbps (9% increase)
beeline
1104 -> 1488 kbps (35% increase)
On average, that’s about a 20% increase in download speed compared to the default Mac OS X settings. I like it.
/mac 〆
permanent link
Sunday, March 19th, 2006
Simple, Free Mac OS X RAM Disk
Michael Parrot offers a freeware RAM Disk creator (Esperance DV) that works great. Get it.
/mac 〆
permanent link
Wednesday, February 1st, 2006
Essential Mac OS X Applications
Mac Specialist provides a very nice list of essential Mac Apps.
/mac 〆
permanent link
Monday, January 9th, 2006
Kariela’s Sandvox
Sandvox looks to be a very promising tool for creating websites
that look great and comply with standards. You can download the public
beta now and try it out.
/mac 〆
permanent link
Wednesday, November 9th, 2005
Here’s Hoping for Launchy
While my normal computing platform of choice is Mac OS X, I do end up
using Windows at work. On OS X, I really love the quick-launching
abilities of LaunchBar and QuickSilver, so naturally I’m
always on the look-out for similar launcher utilities for Windows.
Launchy is a promising start. It was
written for fun by a guy who just wanted it for himself, then shared it
with friends, then shared it with the world. Despite being so young, it
has three of the best features I deem necessary in this strain of
program:
- blazing fast speed
- almost non-existant UI (it only shows up with a keyboard command,
Alt+Space)
- partial pattern matching (typing “mword” matches “Microsoft
Word”)
I would be very happy if only someone could add a bit of:
- manual match tuning
- learning (remember manually tuned matches)
- custom matching (I want to launch stuff that is not in the Start menu)
As for now, I ran it for a few days, but ultimately turned it off.
/mac 〆
permanent link
Friday, September 9th, 2005
Setting bash command history expansion to use the up arrow like MATLAB
This is one of those simple once you know it but annoying to figure out
settings. Via google, I found the solution — add the folling lines
to “.inputrc” in your home directory:
"\e[A": history-search-backward
"\e[B": history-search-forward
For extra fun, you can make the command line cycle through options instead of printing them all when you press TAB. Try adding the following line (via
macosxhints):
TAB: menu-complete
The jury in my head is still out on if I prefer this behavior. I wish
they would just hurry up and decide so I can get used to it.
Update: Note that this takes effect in new terminal windows and new
logins, not your current command line session.
Update 2: Steve suggested an
alternative approach is to add the following lines to “.profile” or
“.bashrc”:
# make bash autocomplete with up arrow
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
# make tab cycle through commands instead of listing
bind '"\t":menu-complete'
/mac 〆
permanent link
Tuesday, August 30th, 2005
Respect the launchd
This saga was enabled by my recent upgrade to Mac OS X 10.4 (the upgrade itself went very smoothly). I decided that I should setup squid to run automagically via launchd. Luckily, faithful reader Steve wrote a tutorial that explaines exactly how this should work.
It’s all working great now, but that took a little doing. I followed Steve’s commands exactly but ran into trouble because of a permissions problem with the cache. Steve recommended changing the permissions (sudo chmod -R 755 /sw/var/cache/) and I now realize that following his advice would have fixed the problem right away.
Instead of listening to the Wise Words of Steve, I decided it would make sense to do a sudo killall launchd. Oops. If I would have read this more carefully, I might have remembered that launchd is now responsible for starting the window manager on Tiger, but alas, I was driven to figure it out without thinking.
So, you might ask at this point: what happens after you sudo killall launchd? As happens often in scientific inquiry, I have stumbled upon the answer to this oft-pondered quandry by chance.
Here’s what happened:
- Apps that were already running continued to run, minus network connections
- New apps wouldn’t launch — the app would bounce in the Dock forever
- Couldn’t Shut Down, Restart, or Log Out
I guess the lesson is: typing sudo killall whatever on stuff you don’t know anything about is probably a bad idea.
/mac 〆
permanent link
Tuesday, August 23rd, 2005
How to see if someone is trying to guess your ssh passwords
Tipped off by this Mac OS X
hint I
went looking to see if anyone might be trying to break into my computer
via scripted ssh login/password guessing attacks. After reading some of
the comments on macosxhints and doing some digging, I figured out a nice
way to check for attacks by using grep to search the system.log files.
zgrep 'Illegal' /private/var/log/system*
zgrep (a variant of grep) searches the archived log files in
addition to the current ones. On my system, this produced a long list
of breakin attempts that look like they are coming from an automated
script running through user names.
I’m not sure if disabling the ssh password, as the hint suggests, is
the best idea to counter this attack (and, I admit, I’m too lazy to
setup the crypto keys thing for now).
For my own home computer, I thought it would be better to only allow
login for myself and keep my password very strong. To accomplish that, I
edited the cooresponding settings in /etc/sshd_config to to the
following:
# Enable only SSH2 protocol (not the less secure SSH1)
Protocol 2
# Don't allow any remote root login
PermitRootLogin no
# Make sure only a particular user (dorkuser) can SSH
AllowUsers dorkuser
That’s it! Much more secure. dorkuser is, of course, not my real
username.
For fun, here’s a look at a processed (minus IPs and my user name)
snippet from the log:
08:38 sshd: Illegal user wwwrun
08:40 sshd: Illegal user wwwrun
08:42 sshd: Illegal user wwwrun
08:44 sshd: Illegal user wwwrun
08:46 sshd: Illegal user wyoming
08:48 sshd: Illegal user wyoming
08:50 sshd: Illegal user wyoming
08:52 sshd: Illegal user 0002593w
08:54 sshd: Illegal user 001
08:56 sshd: Illegal user 1
08:58 sshd: Illegal user 123
09:00 sshd: Illegal user 1234
09:02 sshd: Illegal user 127
09:04 sshd: Illegal user 16
09:06 sshd: Illegal user 1a4
09:08 sshd: Illegal user 1dd
09:10 sshd: Illegal user 22b
09:12 sshd: Illegal user 2a
09:14 sshd: Illegal user 3e
09:16 sshd: Illegal user 4ct
09:18 sshd: Illegal user 511
09:20 sshd: Illegal user 561
09:22 sshd: Illegal user 587
09:24 sshd: Illegal user 72
09:26 sshd: Illegal user 75
09:28 sshd: Illegal user 9ia
09:30 sshd: Illegal user a
09:32 sshd: Illegal user a
09:34 sshd: Illegal user a_kirchner
09:36 sshd: Illegal user a1775b
09:38 sshd: Illegal user a4
09:40 sshd: Illegal user aaaa
09:42 sshd: Illegal user aabraham
09:44 sshd: Illegal user aadriano
09:46 sshd: Illegal user aaghie
09:48 sshd: Illegal user aagt
09:50 sshd: Illegal user aahie
09:52 sshd: Illegal user Aaliyah
09:55 sshd: Illegal user aaltje
09:57 sshd: Illegal user aandjstructural
09:59 sshd: Illegal user aando
10:01 sshd: Illegal user Aaron
10:03 sshd: Illegal user aaron
10:05 sshd: Illegal user aaron2
10:07 sshd: Illegal user aart
10:09 sshd: Illegal user aatef
10:14 sshd: Illegal user aba
10:16 sshd: Illegal user aba
10:18 sshd: Illegal user Aba
10:20 sshd: Illegal user abaintelkam
10:22 sshd: Illegal user abawah
10:24 sshd: Illegal user abby
10:26 sshd: Illegal user abc
10:28 sshd: Illegal user abculp
10:30 sshd: Illegal user abe
/mac 〆
permanent link
Tuesday, June 21st, 2005
Flyakite OSX On a Web Page
The folks at FlyakiteOSX have created a very cool web site that acts
exactly like Mac OS X. Very impressive.
/mac 〆
permanent link
Tuesday, June 21st, 2005
Real-time file usage info in OS X
Jonathan Rentzsch describes the details on how to use the command
line tool fs_usage to discover what files a program is opening, reading,
writing, saving, and so on. This could be is quite useful for figuring out
where a program is storing information or what might be going wrong with
a mis-behaving app.
Update:
For example, the following shows filesystem activity for Safari (-w forces a wide
detailed output and -f filesys shows only file system related output instead of
including network related output too).
sudo fs_usage -w -f filesys Safari
See also:
sc_usage (system call usage statistics)
latency (monitors scheduling
and interrupt latency)
vm_stat (virtural memory statistics)
/mac 〆
permanent link
Monday, May 30th, 2005
Windows Freeware that is Useful
When you’re forced to use Windows, here a good list of freeware
that you might consider installing.
/mac 〆
permanent link
Thursday, January 20th, 2005
ITBWTCL 2k4
A while back, I read In the Beginning … Was the Command Line by Neal
Stephenson and I think it eventually led to overcoming my fear of the
command line and learning to value a text-based interface for some
tasks.
Garret Birkel wrote an interesting update and response to Neil’s
work that I enjoyed reading. This update brings the discussion to 2004
is presented interspersed with the original essay: the format works
well.
/mac 〆
permanent link
Wednesday, December 15th, 2004
iPod Portfolio
I came across an interesting web portfolio created with an
iPod-like interface. It even plays music and switches songs while you’re
viewing it. Check out a screen shot.
/mac 〆
permanent link