Posts
Finnish TV advertising
There are some really good ones here occasionally. They’re holding a competition now and some of last years best clips are also available online. Many of them obviously expect you to understand the language, but there are also a few “universal” ones, like this local carpark ad, for instance. Or this one, that’s actually in English.
Posts
Cannot launch natd
After a power outage, this started happening:
Feb 14 15:36:35 www serveradmin: servermgr_nat: nat config:Error:Cannot launch natd The Appple front-ends (like serveradmin) are not very verbose so I’ve found a good troubleshooting step to be to run the underlying deamon with the same config files, manually:
www:/etc/nat root# natd -config /etc/nat/natd.conf.apple natd: unknown protocol (null). Expected tcp or udp Aha! Indeed, the last line looks weird:
redirect_port (null) (null):3050 When it should be something like:
Posts
Cyrus weirdness
Feb 12 23:35:35 server launchd: edu.cmu.andrew.cyrus.master: exited with exit code: 75 Feb 12 23:35:35 server launchd: edu.cmu.andrew.cyrus.master: respawning too quickly! throttling Feb 12 23:35:35 server launchd: edu.cmu.andrew.cyrus.master: 1 more failure without living at least 60 seconds will cause job removal Feb 12 23:35:35 server launchd: edu.cmu.andrew.cyrus.master: will restart in 10 seconds Feb 12 23:35:45 server master[14119]: empty option value on line 14 of configuration file Feb 12 23:35:45 server master[14119]: exiting That’s just launchd’s special way of saying that that cyrus is not starting up.
Posts
Good Things pt 2- YAML
I got acquinted with YAML during my short run-in with Ruby on Rails (more on this some other day, hopefully). Their official description is:
YAML™ (rhymes with “camel”) is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python.
Absolutely brilliant stuff. What it gives you, is a simple (no joke!) portable data format that’s truly human-readable (indentation, baby!
Posts
RewritesRule
For my thesis, I’m building a simple (there’s that word again!) publishing backend that basically just accepts any kind of media, gives you an interface to catalogue it, creates Torrent metafiles, etc and then spits out XHTML and RSS. For this to look nice, I decided to use Apache’s mod_rewrite to use simple canonical URI’s (like show/get/11, genre/Horror etc), so my rule looked something like this (L flag means it’s the last rule and NC that the regex is case-insensitive)
Posts
Apache 2.2.4 Universal Binary
Long story short, I needed a server-side Python interpreter. For this there’s two options (that I know of) - install Zope and run it along or in place of your existing web server (probably what any intelligent being would do), or go the hard way and run mod_python instead. The latest version works with either httpd 2.0 or later so it won’t run OOtB on OS X. I figured since I’m upgrading my Apache anyway, I may as well grab the latest version.
Posts
Fixing the Lumbard
The G3 “Series” PowerBook is a really good machine for your parents - it looks “mature”, it’s “laptop enough” to take it to the cottage if needed, has a big screen (although pretty dim by today’s standards), runs a browser and email just fine and is cheap. Ours had a problem with the power connect though, requiring them to wedge something under the power connector for it to work. Obviously just a bad contact - a perfect opportunity for some light hardware work.
Posts
iTunes Store tips
1.
Define a shortcut for Power Search. System Preferences > Keyboard & Mouse > Shortcuts > iTunes > Search… I set mine to Cmd -F (odd that that doesn’t focus on the search field, by default) 3.
Wishlists. Just create a playlist and drag stuff from the store to it. Only works with individual tracks, sadly 5.
Don’t forget to de-authorize computer before formatting the HD. It’s OK if you restore from a complete backup (including the stuff under /Volumes).
Posts
AppleScripting Keynote 3
And in particular the add chart command. At first it seems like a really cool thing - easily create beautiful charts out of virtually any source. I was excited to try this with some Webalizer output. Looks like you have two options - the Automator Action or Script Editor
The action produces a chart right off the bat, but the input is weird:
Input: (Anything) Two dimensional array of chart labels and data.
Posts
servermgrd bus error
This happened after a failed attempt to add a signed cert from a CA - servermgrd just crashed. Trying to disable all SSL (/Library/Preferences/com.apple.servermgrd.plist) had no effect. Starting in debug mode just said this:
# servermgrd -d 2007-01-28 23:39:04.717 servermgrd[20540] *** _NSAutoreleaseNoPool(): Object 0x306030 of class NSCFData autoreleased with no pool in place - just leaking 2007-01-28 23:39:04.717 servermgrd[20540] *** _NSAutoreleaseNoPool(): Object 0x306420 of class NSCFData autoreleased with no pool in place - just leaking 2007-01-28 23:39:04.
Posts
An interesting quote
If the Mac was so great, why did it lose? Cost, again. Microsoft concentrated on the software business and unleashed a swarm of cheap component suppliers on Apple hardware. It did not help, either that suits took over during a critical period. (And it hasn’t lost yet. If Apple were to grow the iPod into a cell phone with a web browser, Microsoft would be in big trouble.)
Excerpt taken from Paul Graham’s excellent Hackers & Painters, published in 2004.
Posts
Building universal binaries
So far I’ve had the best success with defining the following before configure:
> export LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386" > export CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc" Sometimes this lead to:
gcc: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags in which case passing –disable-dependency-tracking to configure seemed to help.
Posts
last.fm's Taste-o-meter
I’m not a big fan of social networking sites, but last.fm is different. It actually has a point - you can use it to discover new music, keep tabs on your more distant friends, create groups, track events etc. It’s useful and actually fun to use.
One thing I think could work better is the Taste-o-meter. It seems it’s also the basis of the Neighbours feature. It could be a little smarter - instead of just counting the artists two users have in common, it could compare the relative rarity of that particular artist.
Posts
Postmaster
Giving your (admin) account the “postmaster” alias doesn’t actually do anything because /etc/postfix/aliases hardwires postmaster to root and that sends mail to /dev/null. I fixed this by setting the “root” config var in aliases.
In other news, watch out for failed user-specific crontab entries. Sometimes (more than once) running
> crontab -u user -e will simply hang, creating a tmp.something into /var/cron/tabs. This drives cron mad, eating up all the cycles it can.
Posts
Emulators over RDC
Always remember to keep the sound option at “Play on remote computer”. I tend to leave mine at “Do not play” and then wonder why the S60 emulator will launch and then quit after about 20 seconds.
Posts
Amavis gone haywire
The problem:
Jan 22 17:57:59 server postfix/qmgr[29037]: warning: mail for [127.0.0.1]:10024 is using up 20000 of 20000 active queue entries Jan 22 17:57:59 server postfix/qmgr[29037]: warning: you may need to reduce smtp-amavis connect and helo timeouts Jan 22 17:57:59 server postfix/qmgr[29037]: warning: so that Postfix quickly skips unavailable hosts Jan 22 17:57:59 server postfix/qmgr[29037]: warning: you may need to increase the main.cf minimal_backoff_time and maximal_backoff_time Jan 22 17:57:59 server postfix/qmgr[29037]: warning: so that Postfix wastes less time on undeliverable mail Jan 22 17:57:59 server postfix/qmgr[29037]: warning: you may need to increase the master.
Posts
Bruce Is Back!
The Final Cut mascot. It turns out that starting from 5.1 you have to call up the Video Scopes and control-click in the vectorscope. He’s alot braver now too. You can actually move the FCP windows around and he’ll just sit there. This picture was taken with the Finder as the background:
Posts
As If Nothing Ever Happened
To restore a customised and updated machine so that it looks as if it’s never been booted:
Boot to single-user mode
> mount -uw / > rm -rf /Users/* /var/db/netinfo/local.nidb /var/db/.AppleSetupDone /Library/Preferences/* /Library/Caches/* > shutdown now
Posts
Remembering the QTVR Pan Angle
This only works with Safari:
QT_WriteOBJECT_XHTML ( 'myVRmovie.mov', 800, 600, '', 'controller', 'true', 'id', 'myvrmovie', 'cache', 'true', 'pan', getAngle ()); … where getAngle() just uses a cookie:
function getAngle () { return document.cookie.split ('=')[1]; } … which is set with setAngle () like thus:
function setAngle () { document.cookie = 'angle=' + Math.floor (document.myvrmovie.GetPanAngle ()); } Finally, the hotspots are wired to go through this function:
function openPage (url) { setAngle (); window.
Posts
Creating Empty Files of Any Size
This is again one of those cool things that you could never do with OS 9 or older:
> dd count=`echo $((1024*1024/512*sizeinmegs))` if=/dev/zero of=myfile.zeros Perfect for testing drives, networks or file transfer apps. Update:
man mkfile
Posts
A Good Year
Speaking of MacWorld and Apple history, here’s a “blast from the past” I found while going through some old stuff:
That was a pretty good year! And it’ll be 10 years this year since Jobs came back, btw.
Posts
Revitilizing Camino's Flashblock
I noticed the little FlashBlock checkbox in CaminoTools wasn’t actually doing anything. It’s supposed to disable all flash content until you click on it. Turns out this is achieved with simple CSS and here’s how you enable it:
> cd ~/Library/Application\ Support/Camino/chrome > cat > ./flashblock.css << EOF /* Prevent flash animations from playing until you click on them. */ object[classid$=":D27CDB6E-AE6D-11cf-96B8-444553540000"], object[codebase*="swflash.cab"], object[type="application/x-shockwave-flash"], embed[type="application/x-shockwave-flash"] { -moz-binding: url("http://www.cs.hmc.edu/~jruderma/clickToView.xml#ctv"); } EOF and then just include that css file in your userContent.
Posts
Smartphone Market Share
I’m really excited about the iPhone. Finally a mobile device that looks great, tackles some serious UI problems with fresh ideas and sports a “real” operating system, made by the same house as the HW to boot (although the specs on that one are still nowhere to be found). They could’ve dropped the camera to maybe squeeze some extra batter life out of it, but nevermind. Got me excited about mobile app development again!
Posts
Are We Or Aren't We?
Everyone knows this by now. This is nice and I couldn’t agree more:
However, I found the Chrysler ad they run before this story on time.com to be a little umm… conflicting?
I have a fairly sarcastic sense of humour, but even I don’t get it. Are we or aren’t we? Would be kind of a downer if they ran that after the story.
Posts
I Love Akamai (from now on)
Here’s a cool 22 minute video showing how Akamai works which I found when researching for my thesis. Impressive would be an understatement. It’s a little long, but definitely worth watching if you’re into statistics or online content delivery:
There’s actually all sorts of goodies on their site. Like this Dashboard Widget that shows you how much music business there’s out there or the realtime metrics visualizations. Plus, they look cool too!
Posts
Giving .doc an Icon
I don’t work much with Word files, but when I do, the only major “problem” I have is that if you only have Pages and TextEdit installed, .doc files have a generic-looking white icon. It’s easy to fix though:
/Applications/TextEdit.app > Show package contents > Contents > Resources Duplicate rtf.icns and rename copy to doc.icns From the Contents folder open Info.plist and into the CFBundleDocumentTypes array append:
<dict> <key>CFBundleTypeExtensions</key> <array> <string>doc</string> </array> <key>CFBundleTypeIconFile</key> <string>doc.
Posts
ADC Student Membership
There doesn’t seem to be much info out there on this subject, so here’s my experience. Bought the student membership for 99 EUR, solely for the hardware discount (I’m sure that’s the case for most people). The product listing also says you get the current version of OS X and a copy of XCode as well, but they’re bundled with the machine anyway.
> priceOfMembership=99 > priceOfHardware=1408 > newPriceOfHardware=1275 > echo 'Total discount: ' $(($priceOfHardware-$newPriceOfHardware-$priceOfMembership)) 'EUR (' $(($newPriceOfHardware/$priceOfHardware*100)) '% )' Total discount: 34 EUR ( 0 % ) The percentage is 0 because Bash’s arithmetic’s only deal with integer values (it’s actually about 10%), but it may as well be, because you should also factor in the 30 min on the phone.
Posts
Display Sleep
I usually leave my Mac on when I go to bed. This means setting the display sleep to now or the next best thing, 1 minute. The most obvious way to do it is from System Prefs, but I wanted something faster:
> sudo pmset displaysleep 1 is great, but requires root prvileges (due to some of the other things you can do with it) so it’s out for any kind of automation/scripting purpose.
Posts
Audio Transcoding with Automator
Got a bunch of FLAC files that I wanted to add to the iTunes library. Options: a) install the FLAC component and hope it works b) decode them with flac, import wavs to iTunes, delete the wavs or c) do point b), but with a click of a button:
Pretty nice. I only wish QuickTime Player had such a nice Automator Library…
Posts
Google search to RW (for lazy bums)
A really lazy way to add search to your RW page:
<div id="gsearch"> <form action="http://www.google.com/search"> <input type="text" name="q"/> <input type="hidden" name="hl" value="en"/> <input type="hidden" name="sitesearch" value="http://homepage.mac.com/filipp"/> <input type="submit" value="Search with Google"/> </form> </div> I think you could actually cook up something nice with a Google developer account and XMLHttpRequest…
Posts
Using script.aculo.us with XSLT
When using script.aculo.us with XSLT (XML to XHTML), don’t include like this:
<script src="javascripts/scriptaculous.js" type="text/javascript"> This is because scriptaculous.js uses document.write () to include the components and that’ apparently verboten when using XSL. The symptoms are weird too: * Safari will acts as if all was OK, except Ajax.Request won’t work * Firefox/Gecko-based browsers will just hang on loading the document (an invinite “Reading”) and you’ll notice some class name related errors in the JS log.
Posts
Project sugupuu.com
About 6 months ago, me and my mother wanted to start building our family tree. It quickly became apparent that the Mac software scene is sorely lacking in this area. Most of the mature apps were either dated, didn’t support Unicode (quite frankly an unacceptable flaw in a genealogy app) or were just too cumbersome to use. Family was cute, but lacked some important features (like any kind of textual backup or export).
Posts
Points on ZFS
Snapshots. This feature was the reason people originally thought it was behind Time Machine. “A snapshot is a read-only point-in-time copy of a filesystem which takes practically no time to create and uses no additional space at the beginning. Any snapshot can be cloned to make a read-write filesystem and any snapshot of a filesystem can be restored to the original filesystem to return to the previous state.
Posts
Software For Starving Students
Stumbled across this cool project while browsing through Apple’s Software downloads section. From the project’s homepage:
Software for Starving Students is a free collection of programs organized for students (but available to anyone). We’ve gathered a list of best-in-class programs onto one CD (one disc for OS X, one for Windows), including a fully-featured office suite, a cutting-edge web browser, multi-media packages, academic tools, utilities and more.
I think this is a terrific idea.
Posts
Happy Holidays
The past few days have been weird. Got a really great idea for writing a hwmond replacement called servermond that would allow you to use at least some of the functionality of Server Monitor on any hardware. So far so not good. Getting the SSL decryption to work to reverse-engineer the Server Monitor protocol has been unsuccessful due to, quite frankly, lack of tools. ssldump won’t compile straight, tried the macports version but that won’t run.
Posts
IOHWSensor
Q: Is it possible to read the hardware sensors from the Terminal, without any 3rd party help? A: Yes it is. Q: Mmkay, but how? A: I’m glad yo asked. With ioreg and a few extra utilities, like awk:
ioreg -n IOHWSensor | awk -F "=" '/\"current-value\" = (\d*)|\"location\" = (\d*)/ { print ($2); }' That will output:
3031040 "HDD BOTTOMSIDE" 3309568 "CPU TOPSIDE" 3440640 "GPU ON DIE" 80033 "CPU CORE" 307429376 "REAR MAIN ENCLOSURE" 1900544 "BATTERY" As you can see the numbers don’t make any sense.
Posts
Modulo
This one is easy, but so important but used so rarely that you have time to forget it. How to build a table programmatically with a certain number of columns, with only one while - loop:
<table style="border: 1px solid black"> $i = 0; $col = 4; $val = 20; $table = null; while ($i < $val) { $i++; $table .= '<tr>' + ($i % $col == 0) ? "<td>$i</td></tr>" : "<td>$i</td>"; } print ($table); ?
Posts
Variable Scopes
value = 0 def setValue(): value = 1 setValue () print value What’s that gonna print? That’s right - 0. Must use global instead:
value = 0 def setValue(): global value value = 1 setValue () print value It’s actually the exact same with PHP:
$value = 0; function setValue () { $value = 1; } setValue (); print ("value: " . $value); My brain tells me that if something’s been defined previously, then we should be referencing that thing instead.
Posts
Two New Scripts
useradd.sh and freplace.sh. The first is a simple CLI utility for creating users and the second finds and replaces files.
> ./useradd.sh Usage: sudo useradd.sh [-u uid] [-g group] [-a] [-c] [-d home] [-s shell] [-rn realname] name -a makes new user an administrator.
> ./freplace.sh Usage: freplace.sh [-sb] [-o owner:group] -d indir target replacement Replaces target in directory indir with replacement. Has a few extra features as well.
Posts
About FTP
1) To allow only FTP access to a share (AFP/FTP/SMB):
$ sharing -e sharename -s 010 2) All the configuration files are in /Library/FTPServer/Configuration 3) “man ftpaccess” had some useful info on the different chrootType values:
chroot_type standard | homedir | restricted Sets the type of restricted environment the user is under when he logs on. standard Allows users to access the ftp root, their homedir, and sharepoints. homedir Allows users to access the their homedir and sharepoints.
Posts
Universal Hello World
I’ve been struggling with building universal (fat) binaries on OS X for quite a while now. Finally decided to sit down and figure this out. In a situation with many variables, it’s often good to stop and try to “crystallise” the problem at hand. What better way to do this than with a Hello World - if that won’t compile and link, then why should anything else, right?
#include <stdio.h> int main (void) { printf ("Hello, world!
Posts
DBERROR- critical database situation
OK, so this one started with a rather ominous message in /var/log/mailaccess.log:
Dec 11 15:33:47 gw mbpath[4439]: DBERROR: critical database situation Stopped the server, tried a db rebuild. Nothing. Noticed a “no space on device” error, indeed df confirmed it. On to finding what’s taking up the room:
gw:/Library/Logs root# du -hc -d 1 / 0B /.Trashes 1.5K /.vol 318M /Applications 1.5K /automount 3.5M /bin 0B /cores 2.0K /dev 0B /Groups 1.
Posts
Cheap Bastards
OK, so you’ve got trillions in the bank and you’re taking orders for your next big cash cow. You set up a website, with the product packaging, marketing text and compulsory generic humanoid photo, then you have your graphics team come up with the necessary buttons and icons:
No, wait, that can’t be right. That little icon looks just like:
…THE FRIGGIN WORKGROUP MANAGER ICON! And it doesn’t just look like it - it is the same one.
Posts
Mac Pro Memory and Temperatures
Stumbled across this bit of interesting information. Two interesting points - first, it’s possible to embed thermal sensors onto a memory DIMM:
“In order for the Mac Pro to maintain a safe operating temperature of the FB-DIMMs, the AMBs for each FB-DIMM must provide a functional temperature sensor.”
This is thanks to the SPD (Serial Presence Detect) chip that’s on every DIMM that also supports the I2C protocol.
Posts
BBEdit Session Restore
BBEdit’s probably my most important tool. Even though an editor is such a basic thing that it’s almost kind of silly to be attached to one, you just get used to it over time and it’s nice to constantly be finding new features and ways to use a tool.
I can easily have upwards of 20 documents open simultaneously - sometimes part of the same project, mostly not. This makes you weary of actually closing the app because what if you want to pick up exactly where you left off?
Posts
PHP's file_get_contents () and cookies
Sending cookies - you can do it with file_get_contents () - just look at the stream functions’ constants (the context parameter). But I found out it’s much easier using the curl plugin (which isn’t always available, btw, but neither is file_get_contents ()):
$c = curl_init ($url); curl_setopt ($c, CURLOPT_VERBOSE, 1); // For testing curl_setopt ($c, CURLOPT_COOKIE, "variable=value"); curl_exec ($c); It’s that simple. An awesome tool for creating all kinds of site parsers.
Posts
A Free Alternative To MatLab
You can stitch one together with the following components: Apple’s X11 + AquaTerm + Gnuplot 4 + Octave
It’s all here.
Posts
Something New Every Day...
JavaScript - Associative Arrays Considered Harmful The reason I stumbled across this was that Apple’s QuickTime Embedding JS has this problem. The symptoms look crazy - you’ll have other JS code inside your embed tag. This happened to me when using Prototype. The fix is easy - just replace “new Array ();” on line 165 with “new Object ();”
Posts
No More OpenWiFi From Me!
My net connection was dropped yesterday. After the standard reboot/check/repeat procedures I decided to call the ISP. The customer service person was happy to report that this was not a glitch, but that my connection had been cut due to too much spam coming from my modem…
I was of course a little surprised. We have 3 Macs + 1 Debian box in our home network, none of which, I’m pretty sure, are spamming.