Pecunia's Blog

Mac OS X: remove quarantine status from files

Posted on 2011-02-05 08:34:58

On Mac OS X, downloaded files (via Firefox) have an extended attribute on their file permissions, visible by the ‘@’:

[bianca@charon Downloads]$ ls -l Zend*
-rw-r--r--@ 1 bianca  staff   3738873 Feb  4 19:17 ZendFramework-1.11.3-minimal.tar.gz
-rw-r--r--@ 1 bianca  staff  20025817 Feb  4 19:17 ZendFramework-1.11.3.tar.gz

These extended attributes can be shown with xattr:

[bianca@charon Downloads]$ xattr -l ZendFramework-1.11.3-minimal.tar.gz
com.apple.quarantine: 0000;4cf55482;Firefox.app;|org.mozilla.firefox

OS X sometimes asks whether it’s safe to open these files. To make things worse, unzipping or untarring such a downloaded file applies the extended attribute to all extracted files…

To get rid of it on a per-file basis:

xattr -d FILE

To recursively remove the attribute from all files/directories:

find . | xargs xattr -d com.apple.quarantine
Posted in: Computers, OS X

Deploying midlets to a Nokia phone over Bluetooth

Posted on 2011-01-09 21:09:56

So I had built a lovely little application (midlet) using the Java Micro Edition, and wanted to deploy that to my Nokia 3120 phone. I don’t have a USB cable for connecting my phone to my desktop, I don’t have a data plan so I couldn’t host it somewhere and then download it on my phone, but I do have a Bluetooth-enabled MacBook (on which the Nokia PC Suite doesn’t run).

When browsing the device using Bluetooth file exchange, only the folders available in Media show up. How to get it deployed on my phone in the Apps folder where it belongs?

The answer is simple once you know it:

  1. Attempt to create a folder named ‘Applications’ at the root level
  2. That folder already exists, so the file browser just moves into it
  3. Browse to the folder within applications where you want to drop the app
  4. Upload the .jad and .jar
  5. Done!
Posted in: Computers, Personal

Implementing IComparable

Posted on 2010-08-24 10:55:10

In the most recent project I’m working on at work, we’re using a self-made generator for generating the business entities. The generator creates the class, properties, and implements the IComparable interface.

IComparable contains a CompareTo() method that should return 0 when the objects are equal, a negative value if the current object is less than the other, and positive if the current object is greater than the other.

A generated class looks like this:

public class SomeObject
{
    ... properties ...
    public int CompareTo(SomeObject other)
    {
        if (Id = = other.Id &&
            Name = = other.Name &&
            SomeProperty = = other.SomeProperty &&
            SomeOtherProperty = = other.SomeOtherProperty)
            return 0;
        else
            return 1;
    }
}

It’s a good thing the business entities are not actually compared to each other, but only checked for equality. Sorting these objects will be a downright failure…

Posted in: Work

Oracle inequality

Posted on 2010-06-08 19:24:07

While converting a bit of Oracle PL/SQL to Java today, I found this nugget:

if to_number(nvl(r_status.some_field,0)) < 2 or
   to_number(nvl(r_status.some_field,0)) > 2
then
  -- do something
end if;

Obviously the coder who wrote this has never heard of the ‘<>’ and ‘!=’ operators…

Posted in: Computers, Work

Server backup system

Posted on 2010-01-10 17:52:42

My home server is 10 years old now: it’s running this website, my personal intranet, a svn server and some other websites, and before today I didn’t have any backup system in place. The last backup I have of the data dates back to April 2008, so I decided it was time to have a proper backup system. Particularly since the server is somewhat ageing.

My idea:

  1. Tar and gzip the entire /home folder every night using a cron job. All SVN, MySQL and Apache data is stored in /home (good thing I set it up that way), so that’ll cover everything that might change daily
  2. Every month, make a copy of the entire system, in addition to the daily backup of /home
  3. Copy the .tar.gz backup file(s) to my desktop computer every day. The desktop computer has enough space for storing the backups: the compressed home directory is just over 100MB.

That way, I will lose at most one day of data, which isn’t much of a problem.

Read more...
Posted in: Computers, Linux