Archive: Mac
August 26, 2008
Dealing with large numbers of files in Unix
Most of the time, you can move a bunch of files from one folder to another by running a simple mv command like "mv sourcedir/* destdir/". The problem is that when that asterisk gets expanded, each file in the directory is added as a command line parameter to the mv command. If sourcedir contains a lot of files, this can overflow the command line buffer, resulting in a mysterious "Too many arguments" error.
I ran into this problem recently while trying to manage a directory that had over a million files in it. It's not every day you run across a directory that contains a metric crap-ton of files, but when the problem arises, there's an easy way to deal with it. The trick is to use the handy xargs program, which is designed to take a big list as stdin and separate it as arguments to another command:
find sourcedir -type f -print | xargs -l1 -i mv {} destdir/
The -l1 tells xargs to only use one argument at a time to pass to mv. The -i parameter tells xargs to replace the {} with the argument. This command will execute mv for each file in the directory. Ideally, you would optimize this and specify something like -l50, sending mv 50 files at a time to move. This is how I remember xargs working on other Unix systems, but the GNU xargs that I have on my Linux box forces the number of arguments to 1 any time the -i is invoked. Either way, it gets the job done.
Without the -i, the -l parameter will work in Linux, but you can no longer use the {} substitution and all parameters are placed as the final arguments in the command. This is useless for when you want to add a final parameter such as the destination directory for the mv command. On the other hand, it's helpful for commands that will end with your file parameters, such as when you are batch removing files with rm.
Oddly enough, in OS X the parameters for xargs are a bit wonky and capitalized. The good news is that you can invoke the parameter substitution with multiple arguments at a time. To move a bunch of files in OS X, 50 files at a time, try the following:
find sourcedir -type f -print | xargs -L50 -I{} mv {} destdir/
That's about all there is to it. This is just a basic example, but once you get used to using xargs and find together, it's pretty easy to tweak the find parameters and move files around based on their date, permissions or file extension.
Posted by Jason Striegel |
Aug 26, 2008 07:22 PM
Linux, Linux Server, Mac |
Permalink
| Comments (6)
| TrackBack
| Digg It
| Tag w/del.icio.us
August 17, 2008
Use iPhone version of Google Reader on your Mac

I'm fond of iPhone-specific versions of web sites; they usually have just the minimal set of features you need and are very easy to use. Adam Darowski just posted a great way to get the iPhone version of Google Reader running on a Mac as a desktop app:
Do you find yourself checking feeds on your iPhone and thinking, "Man... I wish Google Reader looked like this on my computer, too." I have. Using Fluid.app and a bit of user agent trickery, you can make it happen...
Read all about it; thanks to Adam's instructions, you can get this going yourself in minutes. Using Fluid.app to Bring Google Reader for iPhone to your Desktop
Posted by Brian Jepson |
Aug 17, 2008 01:16 PM
Google, Mac, iPhone |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
August 9, 2008
Edit binary files in Vi

If you've ever wanted to examine or edit a binary file in your favorite text editor, there's an easy way to simulate a vi hex mode. To do this, you just filter the file's contents through the xxd hex dump utility, a trick that can be accomplished right within the vi/vim interface.
To convert a file to hex dump representation, just load your file in vi and type the following:
:%!xxd
This sends the entire contents of the opened document to xxd and loads in the result. At this point, you can view or edit any of the hex data. The ASCII representation is listed to the right, though editing this region will not affect the hex portion of the file.
When you are done, you'll want to convert things back into their binary format before saving. To do this, you run things through xxd again, but this time with the -r option:
:%!xxd -r
Your file should be returned to illegible gibberish, which you can save back out with :wq.
A funny thing I just noticed: OS X binaries all start with the same 4 bytes which, in hex, spell out the phrase "cafe babe". This is just a magic number used to identify the file as an OS X binary, but it's hard not to ascribe some deeper meaning. ;)
Posted by Jason Striegel |
Aug 9, 2008 10:00 PM
Linux, Mac |
Permalink
| Comments (5)
| TrackBack
| Digg It
| Tag w/del.icio.us
August 8, 2008
Dell Inspiron 1525 HackBook Pro

Richard from EspressoReport put together a thorough tutorial that will get you up and running with OS X Leopard on a Dell Inspiron. Arguably, it's not the most sexy hardware, but at the $650 list price with dual core performance and the natively supported graphics chip (same as the MacBook's), it's not a shabby alternative to running OS X on Apple hardware.
Under the hood boasts a little bit older processor technology with a 533MHz FSB -- Intel Pentium Dual Core. This is very similar to the new Celeron Dual Cores but don't let it confuse you with the Pentium D -- this CPU is actually rather nice. Although using the Pentium name, the Pentium Dual Core is based on the Core technology you're already familar with on your Core Duo and Core2 Duo Macs. While the battery doesn't last quite as long as a similar Core2 Duo (Centrino), this 1.87GHz packs a punch and unlike all you other dual core users, I don't have to boot with cpus=1 -- that's right! This HackBook Pro is using both cores and it's putting out some power with Mac OS X.
Of course, you'll have to wrangle with the ethics of installing OS X on hardware that Apple doesn't wish you to. Perhaps the thought of ridding an innocent laptop of Vista will provide you with some solace.
Dell Inspiron 1525 HackBook Pro Tutorial
Posted by Jason Striegel |
Aug 8, 2008 09:39 PM
Mac, PCs |
Permalink
| Comments (1)
| TrackBack
| Digg It
| Tag w/del.icio.us
June 29, 2008
Objective-J and Cappuccino: Cocoa for the web

There's a neat article over at Ars Technica that takes a look at 280 North's 3-person development team, their recent release of a keynote-like web application called 280 Slides, and the framework that they constructed to make the application. Some time before 280 Slides was developed, the team created an Objective-C-like superset of the Javascript language called Objective-J which implements message passing and a Smalltalk-style syntax. Building on that, they re-implemented much of the Cocoa framework in Objective-J, allowing Cocoa-style applications to be developed that will run natively in the browser.
With Objective-J and Cappuccino, you don't create applications with a mixture of HTML, CSS and Javascript. Instead, apps are written entirely in Objective-J, following a development model that's similar to creating desktop applications for OS X. From the article:
"Cappuccino is a re-implementation of Cocoa in Objective-J, which means we reimplemented AppKit, Foundation, CoreGraphics, and parts of CoreAnimation," Boucher told us. With it, developers familiar with desktop GUI applications can create a rich, desktop-like web app with the same relative ease Cocoa programmers can create a rich desktop app. "Coming from a background of desktop programming, and Cocoa in particular, we realized how much harder building a web application was. So we wanted to try to make things just a little bit easier."
280 Slides stands on its own as a powerful web-based presentation tool. It's simplified when compared to its desktop cousins, but it does exactly what most people need in a presentation tool, and it can export to PPT for fine tuning and end-presentation use. The fact that its development inspired the creation of a new language as well as bringing a desktop application development framework to the web just blows my mind.
Objective-J will be released to the public soon as an open source project. On the one hand, I'm not sure if I'm comfortable moving away from the web development technologies I've grown accustomed to. On the other, it would be cool to work in a language that allows you to seamlessly port your applications between the desktop and the web.
If you have experience with both Cocoa and AJAX development, please share your thoughts in the comment area.
Cocoa on the web: 280 North, Objective-J, and Cappuccino [via Slashdot]
280 North Blog
280 Slides
Objective-J.org
Posted by Jason Striegel |
Jun 29, 2008 08:36 PM
Ajax, Mac, Software Engineering, Web |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
June 5, 2008
DIY Slingbox

Using a standard DV cam, a Mac Mini, and the Quicktime Broadcaster utility, you can roll your own Slingbox-style TV streamer on the cheap. David Glover, realizing that his DV camera had an analog input and firewire output, put together a howto for doing just this:
Yesterday from a dusty shelf I discovered my Sony DV camera. And after playing with it for a while I discovered (or possibly re-discovered, as I might have just forgotten) that it has analogue video inputs that it will digitise and then spit out of the DV port.So this gave me an idea - this is essentially what the Slingbox does, except the Slingbox outputs a network stream rather than DV video. But I have a Mac Mini sitting underneath my TV downstairs, and that has a DV port on it...
This is really handy if you want to catch a show on your computer while you are working from another room. Assuming you also have a DV camera and a spare Mac you can connect to your TV, it's also essentially free.
DIY Slingbox
QuickTime Broadcaster - Apple's free video transcoder and streaming utility
Posted by Jason Striegel |
Jun 5, 2008 08:26 PM
Mac, Video |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
May 22, 2008
Keywurl: keyword search for Safari

Keywurl is a nifty little Safari plugin that adds simple keyword search to the address bar. Say you wanted to pull up the Wikipedia entry for hacks: just type "wiki hacks" into the address bar. Looking for photos tagged with makerfaire? "flickr makerfaire" will take you to the appropriate place.
The latest beta version for Leopard allows you to right click on any form field and add a search shortcut keyword for it. This would easily let you add keywords like "hacks" or "slashdot" that would let you query for articles on your favorite sites. Unfortunately, there isn't a Tiger build of this version yet, so revision slackers like me will have to wait. You can also get at the keyword settings manually through a new button in the Safari preferences panel.
I haven't been using this long enough to tell if I'm going to keep it, but so far it's really promising. At the very least, it sends me to the right place when I type in a search term into the address bar instead of the search bar by accident.
Posted by Jason Striegel |
May 22, 2008 09:47 PM
Life, Mac |
Permalink
| Comments (1)
| TrackBack
| Digg It
| Tag w/del.icio.us
May 8, 2008
DIY multi-touch on OS X

Bridger Maxwell has been blogging his progress on creating a homebrew multi-touch platform in OS X. Prior to this, there's been a lot of activity around building multi-touch systems on Windows using the Touchlib library, but this is the first time I've seen a concerted effort on OS X.
The basic hardware is the same for both environments: LEDs surround a sheet of acrylic, causing a backscatter of IR when fingers are pressed to the screen. On the software side, though, the multi-touch interface is provided through Pawel Solyga's OpenTouch library. From the sounds of things, though, it's not super simple getting the interface messages from OpenTouch to your multi-touch enabled Cocoa apps:
Both OpenTouch and TouchLib send the touch data to other applications by sending Tangible User Interface Object (TUIO) network messages. TUIO is a protocol that is designed for transmitting the state of multi-touch systems. TUIO is built upon another protocol, Open Sound Control (OSC). While libraries for receiving TUIO messages are available in a few languages such as C++ or Java, there was not a solution for Cocoa applications. My first step was to build a library for receiving TUIO messages in Cocoa.Because TUIO is built upon OSC, I looked for a library that could parse OSC messages. Unfortunately, I could not find one that would fill all my needs. WSOSC was a library that came close though. There were a few issues to work around (use NSData instead of NSString), but eventually I was able to use WSOSC to parse the OSC packets. When finished, my framework had the ability to parse TUIO messages and had a method to delegate the TUIOCursor objects it created to another application.
From the blog comments, it sounds like Bridger is planning on releasing this middle layer when it gets a little further along. At the moment, though, he's released a demo comic viewing application that uses his multi-touch project framework. If you're interested in developing multi-touch apps for OS X, some of the discussions on Bridger's blog would be a good place to start.
Bridger's Multi-Touch Blog
OpenTouch Library
See also:
Make your own multitouch displays and software apps
Posted by Jason Striegel |
May 8, 2008 08:43 PM
Mac, Software Engineering |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
April 23, 2008
Scriptographer - Javascript for Illustrator

My friend Barrett sent along a link today to an Illustrator scripting plugin called Scriptographer. I'm sort of a slouch at Illustrator, so I had him give me the quick 411 and I must say, this is pretty cool.
If you're familiar with Javascript, Scriptographer will enable you to crank out little scripts that can generate illustrations procedurally. As an example, the bubbelbubbling script, show above, tuns your pen tool into a fountain of random bubbles that follow your drawing path. There are certain styles of artwork that could really lend themselves to a procedural drawing tool: fractals, patterns, random "particle" effects. These things would take forever to generate manually, but by defining the effect programatically, you can quickly experiment with your work in a more dynamic fashion, tweaking variables and fine-tuning your work as you go.
The project website also has a growing library of user-contributed scripts that are worth checking out. It's a good place to start for your own creations, or you may just find exactly what you're looking for, already crafted for you by another designer-coder.
Posted by Jason Striegel |
Apr 23, 2008 09:11 PM
Design, Life, Mac, Software Engineering |
Permalink
| Comments (1)
| TrackBack
| Digg It
| Tag w/del.icio.us
April 19, 2008
Manipulating Mac keyboard LEDs through software
Amit Singh, the Google Mac Team hacker who taught us all how to use the Mac motion sensor as a human interface device and manipulate the keyboard backlight on the MacBook Pro, wrote a short program that demonstrates how to control the LEDs on your keyboard through a user space program:
If you have an irrepressible urge to turn these LEDs on or off through software, here is a program that shows you how. (Note that the program only manipulates the LEDs -- it will not actually cause caps lock or num lock to be engaged.) The program also serves as an example of how to do user-space Human Interface Device (HID) programming through the I/O Kit.
I'm not sure what you could use this for, but that's for you to sort out, right?
Manipulating keyboard LEDs through software
Reading and manipulating the keyboard backlight on the MacBook Pro
Hacking the sudden motion sensor
Posted by Jason Striegel |
Apr 19, 2008 09:46 PM
Mac |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
March 28, 2008
CSS ad blocking for Firefox and Safari
Using Firefox's CSS-based chrome feature or Safari's advanced stylesheet preferences and a little clever CSS coding, you can disable most banner ads, making them invisible in your browser. This technique is considerably easier and more flexible than setting up a private DNS server or proxy to filter out images from ad-serving domains.
The trick is setting up a number of CSS rules that use "*=" substring selection on an element's properties. For instance, matching an IFRAME tag with the SRC parameter containing doubleclick would look like IFRAME[SRC*="doubleclick"] and matching an anchor tag with an HREF containing a url with "ads." in it would look like A:link[HREF*="ads."]. Giving the style "display: none ! important" to all of the possible combinations and adding the stylesheet to your browser's chrome effectively turns off the ad-serving web. The site below has a comprehensive CSS file that's been tailored to assassinate ads from most networks.
To be honest, I didn't realize that you could do this type of parameter matching and subselection in CSS, so it's worth looking at the CSS source for that alone. If you don't use it for this purpose, perhaps the technique will come in handy for something else you are working on.
Better Ad Blocking for Firefox, Mozilla, Camino, and Safari
Ad Blocking userContent.css
Posted by Jason Striegel |
Mar 28, 2008 09:20 PM
Firefox, Life, Lifehacker, Mac, Web |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
March 25, 2008
iNoteBook: repurpose an old laptop

It seems like I end up updating my laptop every couple of years, but as cool as new hardware is, sometimes the challenge of finding a new use for the old machine is more interesting. The iNoteBook mod is a classic example, transforming a broken, screenless iBook into a stealth desktop machine.
What's your favorite laptop reuse project? If you've got one, please share in in the comments.
Posted by Jason Striegel |
Mar 25, 2008 07:56 PM
Hardware, Home, Mac, Retro Computing |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
March 24, 2008
Safari single window mode
Dennis Stevense posted a great little Terminal hack which enables single window browsing for the latest version of Safari. If you're running 3.1 you can type in the following command to make all "target='_blank'" links open in a new tab instead of in a new window:
defaults write com.apple.Safari TargetedClicksCreateTabs -bool true
This is one of my favorite Firefox features, so I'm pretty happy to see it available in Safari, even if it's under a hidden setting.
How to enable single window mode in Safari
Posted by Jason Striegel |
Mar 24, 2008 09:30 PM
Mac |
Permalink
| Comments (1)
| TrackBack
| Digg It
| Tag w/del.icio.us
March 11, 2008
N64 emulation: better than the real thing

Racketboy has a great article showing off some of the capabilities of the modern N64 emulator. If your machine is fast enough, most of the available emulators will really give you a noticeable resolution boost and better looking anti-aliased models. Using the Rice Video plugin with the Project64 emulator, you can even swap out the textures for some games with user-created texture packs.
I still use the real hardware (is the N64 considered "retro" now?), so before seeing this, I hadn't even considered emulation for this platform. That all changed when I saw the Mario64 mod shown above. The selection of available emulators is impressive, and there are open source emulators available for just about every platform. I'm currently playing a game under Mupen64 on my iMac and it's pretty flawless. My only wish is that all computers came, by default, with a nice joystick like they did back in the 80s.
Enhance N64 Graphics With Emulation Plugins & Texture Packs - Link
Project64 Emulator - Link
Rice Video Plugin - Link
Mupen64 Emulator (cross-platform, open source) - Link
Posted by Jason Striegel |
Mar 11, 2008 10:35 PM
Gaming, Linux, Mac, Retro Gaming, Virtualization, Windows |
Permalink
| Comments (3)
| TrackBack
| Digg It
| Tag w/del.icio.us
March 9, 2008
Command line Twitter
You can easily update your Twitter status from the command line using cURL. The Tech-Recipes blog posted this handy command line hack:
With cURL installed, you can post to Twitter from the terminal window by using the following syntax:
curl -u yourusername:yourpassword -d status="Your Message Here" http://twitter.com/statuses/update.xmlYou will receive a response containing the XML coding for your post which acts as a confirmation that your post was submitted.
Consider this: instant messaging is the new talk (phone for my VMS peeps) and Twitter is the new finger. It's nice to see at least one of these handy communication tools make its way back to the command line.
Posting to Twitter from the Terminal Window - Link
cURL downloads - Link
Posted by Jason Striegel |
Mar 9, 2008 09:39 PM
Linux, Mac, Ubuntu, Windows |
Permalink
| Comments (3)
| TrackBack
| Digg It
| Tag w/del.icio.us
Bloggers
Welcome to the Hacks Blog!
Categories
- Ajax
- Amazon
- AppleTV
- Astronomy
- Baseball
- BlackBerry
- Blogging
- Body
- Cars
- Cryptography
- Data
- Design
- Education
- Electronics
- Energy
- Events
- Excel
- Excerpts
- Firefox
- Flash
- Flickr
- Flying Things
- Food
- Gaming
- Gmail
- Google Earth
- Google Maps
- Government
- Greasemonkey
- Hacks Series
- Hackszine Podcast
- Halo
- Hardware
- Home
- Home Theater
- iPhone
- iPod
- IRC
- iTunes
- Java
- Kindle
- Knoppix
- Language
- LEGO
- Life
- Lifehacker
- Linux
- Linux Desktop
- Linux Multimedia
- Linux Server
- Mac
- Mapping
- Math
- Microsoft Office
- Mind
- Mind Performance
- Mobile Phones
- Music
- MySpace
- MySQL
- NetFlix
- Network Security
- olpc
- OpenOffice
- Outdoor
- Parenting
- PCs
- PDAs
- Perl
- Philosophy
- Photography
- PHP
- Pleo
- Podcast
- Podcasting
- Productivity
- PSP
- Retro Computing
- Retro Gaming
- Science
- Screencasts
- Security
- Shopping
- Skype
- Smart Home
- Software Engineering
- Sports
- SQL
- Statistics
- Survival
- TiVo
- Transportation
- Travel
- Ubuntu
- Video
- Virtualization
- Visual Studio
- VoIP
- Web
- Web Site Measurement
- Windows
- Windows Server
- Wireless
- Word
- World
- Xbox
- Yahoo!
- YouTube
Archives
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
Recent Posts
- Electronics hacking lab in a cigar box
- Making Windows XP play a little better with solid state drives
- Cooking a meal on one 10" grill
- 2008 Interactive Fiction competition entries available
- iPhone Hacks: tips & tools for unlocking the power of your iPhone and iPod Touch
- Today is the last day of the 10% off everything sale at the Maker Shed store, order something now
- Make Dragon's Lair-style games on YouTube
- Controlling a Nikon or Canon camera with a Nintendo DS
- Zoom H2 microphone modification
- Sweetcron - open source lifestream
www.flickr.com
|






Recent comments