OS X: Restoring Addressbook-Entries with Time Machine

Everyone agrees, that Time Machine makes your life a lot easier. Did you know about the fact, that programmers are able to integrate it into their applications?

For example, open iCal and click on Time Machine in the Dock. Now you are able to move back in time and restore deleted or changed entries. Sneaky. ;)

But the fun does not stop here, you are able to restore mailboxes as well. The mechanism does not work with RSS-Feeds in Mail, though.

Leopard 10.5.1 Update

It’s update-day today. First 10.4.11 now 10.5.1.

No problems with 10.4.11 so far.

I installed the 10.5.1 update via software update first and got a couple of messages while repairing permissions afterwards. A bunch of SUID program … not repaired to be precise. I decided to download the combined patch from Apple’s download section and applied it as well. The messages are gone, except the one about ARD which appeared after the initial install of Leopard. This seems to be a known problem according to this message, though.

Tiger Update 10.4.11

Apple released the 10.4.11 Update, it includes the Security Update 2007-008. Based on the information in the links, get it ASAP, seriously.

As a bonus, Apple added support for some more cameras:

Adds RAW image decoding support for the following cameras: Panasonic Lumix DMC-FZ50, Leica V-Lux 1, Olympus E-400, Olympus EVOLT E410, Olympus EVOLT E510, Canon EOS 40D

TextMate Docbook-Bundle soon

[Update: My TextMate-Bundle for DocBook is online, see My DocBook-Bundle for TextMate. It took me quite a while, I know.]

All right, I give up. To all the people who nagged me about my Docbook-Bundle for TextMate:

I’ll put it up here in the next couple of days.

Be warned though, it’s not full-blown, it only does what I need. I just have to sort out a couple of things. Still want it?

Watch this space.

OS X: Console Login

Ever wondered how to log into OS X without the pretty windows? It’s a BSD-system after all. Why would anyone want to do that? If you managed to get your system in a state where the usual login simply does not work any more, for example. Let’s say you created a LaunchAgent, everything looked peachy, you installed it, rebooted and as soon as you log into an account everything goes haywire.

To cut a long story short, if—for whatever reason—you are not able to log in normally, and you know what to do about it, you either need to ssh into the machine or you have to log in using the console. But how do you do that?

Simple, your login-dialog needs to be set to “name and password”, though. Enter >console as username (the “>” is no typo) and hit ↩ (no password). The screen changes to a run-of-the-mill terminal, you probably have to press ↩ again to be greeted by a standard login-prompt. Remember to use the credentials of an administrative account since “normal” users are not allowed to use sudo. To revert back to normal use sudo reboot.

Disclaimer: It works for me, YMMV. I’m not responsible for any damage you inflict on your system, be careful. ;)

Technorati Tags: ,

iTunes: How to Print a Jewel Case Insert

Something many people miss, because it’s just not that obvious: Mark a playlist in iTunes, select “File > Print…” and voila:

Print-dialog iTunes

It’s that easy, it’s a Mac. ;)

Ruby: Simple Calculation of Billable Time using Epoch-Seconds

How to calculate billable time in Ruby using epoch-seconds. Out of interest,I ported the Perl-Code to Ruby and have to say, wow. Ruby is very elegant (not sure if my code is, but it works).

The idea was to use another (scripting-)language readily available on OS X. As I said already, it works like the Perl-version:


#!/usr/bin/ruby

# Variables
starttime = Time.now
epochtime = starttime.to_i

# write to file
timetemp = File.new("timetemp.txt", "w+")

timetemp.puts epochtime

timetemp.close # always close files

#output information for copying
puts "customer|topic"
puts "Start: #{starttime}"
puts ""

start_record.rb gets the current time in epoch-seconds and writes it to a file called timetemp.txt in the same directory. Nothing new here, but I like the construct timetemp.puts epochtime, Ruby is very clean. ;)

When you’re done, end_record.rb is used to read in the starting time and to perform the necessary calculations:


#!/usr/bin/ruby

# Variables
endtime = Time.now
endsecs = endtime.to_i

# open the file
timetemp = File.open("timetemp.txt")

startsecs = timetemp.readline.to_i

timetemp.close # always close files

#calculations
starttime = Time.at(startsecs)

timesecs = endsecs - startsecs

timeminutes = (timesecs.to_f / 60)

timehours = (timeminutes / 60)

# output results
puts "Start: #{starttime}"
puts "End: #{endtime}"
puts "Seconds: #{timesecs}"
puts "Minutes: #{timeminutes}"
puts "Hours: #{timehours}"
puts ""
puts "Bill: "
puts ""

If you don’t want to copy and paste from the terminal-window, simply pipe the results to a file like this:

$ > ruby start_record.rb > my_file.txt

and when you’re done

$ > ruby end_record.rb >> my_file.txt

Remember though, > means overwrite the file if it exists. If you want to append, use >>. This might be obvious to most people fluent in UNIX, but should be noted as a “just in case you need to know”. ;)

Technorati Tags: , , , ,

OS X: More than one E-Mail Address in a Single Account

Did you ever wonder if it’s possible to maintain more than one e-mail sender-address for a single account in Mail.app? Then this post is for you.

The reasons for sending mail—seemingly originating from different mail-accounts—are manifold, not all with good intentions, but let’s concentrate on valid reasons to do so. For example:

  • All your e-mails are sent from your domain mydomain.com.
  • Your “regular” e-mail address is myname@mydomain.com.

So far, so good. Let’s assume you are developing software and you want to differentiate incoming mails regarding your software-package from all the other mails. The software is called mygreatsw. You could set up another mail-account mygreatsw@mydomain.com, but then you’ll have to deal with two mailboxes. There is another way, if you are using Mail.app, that is.

Open your “Preferences”-Panel in Mail.app and klick on “Accounts”. Activate the mail-account in question and add ,mygreatsw@mydomain.com to your already existing mailaddress myname@mydomain.com. The comma is important. The textbox “Email Address” should look like this now: myname@mydomain.com,mygreatsw@mydomain.com.

If you send a new e-mail now, there is a pop-up menu in the “Account”-line, allowing you to send the mail from myname@mydomain.com or mygreatsw@mydomain.com.

It is that simple, but often overlooked. Just in case you need to know.

Technorati Tags: , , ,

Simple Calculation of Billable Time using epoch-seconds

Every freelancer uses some kind of accounting-package to keep track of the billable time, but, given multiple machines, on-site gigs and the like, keeping track is not always that easy, isn’t it? For that reason, I came up with a really simple combination of two Perl-scripts.

The first one, start_record.pl, writes the epoch-seconds to a temporary file and prints some information to the terminal-window.

Update: Thanks to Hebikai for pointing out a problem with the relative path, the scripts are using the environment-variable $HOME to determine the path now.


#!/usr/bin/perl

$HOME_dir = $ENV{HOME};
$DATA_dir = "$HOME_dir/work/time_control_stuff";

$start_time = time;

#print "Seconds: $start_time\n";

print "customer|topic\n";
print "Remarks: \n";
print localtime($start_time)."\n";

open(MY_HANDLE, ">$DATA_dir/time.log") or die "$0: something went wrong: $!\n";
print MY_HANDLE $start_time."\n";
close(MY_HANDLE);

The script assumes, that there is a directory called time_control_stuff in ~/work/. Its output should be copied or piped into a file, it records the time you started. If you want, feel free to modify the customer|topic and Remarks lines to taste.

If you are done with the task, the end_record.pl script comes into play.


#!/usr/bin/perl
$HOME_dir = $ENV{HOME};
$DATA_dir = "$HOME_dir/work/time_control_stuff";
$end_time = time;

open(MY_HANDLE, "$DATA_dir/time.log") or die "$0: something went wrong: $!\n";

while()
{
chop;
$start_time = $_;

}

$total_time = $end_time - $start_time;
$total_mins = $total_time/60;
$total_hours = $total_mins/60;

print "Start: ".localtime($start_time)."\n";

print "End: ".localtime($end_time)."\n";

print "Total: ".$total_time."\n";
print "Mins: $total_mins\n";
print "Hours: $total_hours\n";
print "\nBill: \n\n";

Its output is pretty much self-explanatory, copy or append to the same file and you are done.

I use an USB-stick to carry the scripts with me all the time. If I need to record billable time and don’t have access to one of my machines, these scripts are my way to go. I input the recorded data into my accounting-package as soon as I’m able to do so.

Granted, they could be a lot more sophisticated, but remember KISS (Keep It Simple S…) rules. Use the scripts as a starting-point for you “accounting on the road.”

Getting the current time in epoch-seconds

I already wrote about epoch-seconds, but there is a quicker way to get them, this time without resorting to Perl.

$ date "+%s"

Will return the current epoch-seconds, at the time of this writing 1191687083. This should work with most incarnations of the date-command. For the restless (a.k.a. the ones not willing to read the post linked to above), converting from epoch-seconds to human-readable time works like this:

$ date -r 1191687083

Or whatever second-count you want to convert, of course. One last thing to try:

$ date -r 0000000000

Returns the time your system deems to be the beginning of its time, usually January 1st 1970.

I have no idea, if some of this works on Windows™, it should though, if you’d install cygwin on it.

Technorati Tags: , , ,