2 sie 2011

What folders do I exclude from my TimeMachine backups?

TimeMachine is ment to be a one-for-all solution for backups on Mac. You can backup your entire hard drive (to an external storage, like TimeCapsule device or a USB-drive) and in case of a crash restore your system in an instant. This, however, requires lots of free space on the external drive.

You can also backup only the important folders, then in case of a crash you have to do a reinstall of your system from your installation CD, then restore the backed up folders. This allows you to save some space on the drive you use for backups (hence, you can keep more backups or backup more then one Mac to the same drive).

With some experimentation I found out a few folders that are good to exclude from the backups. The usual ones are:

  • ~/Downloads - this is where stuff downloaded from the Internet goes. Usually you can just re-download it when needed. 
  • ~/Movies - well, I can re-download or re-rip the movies I have as well. Huge space saver. 
  • ~/.Trash and /.Trashes - who needs a trash backed up? Especially those folders change a lot.
  • ~/Applications and /Applications - you can back those up, but also you can just reinstall the apps (especially if you installed them via Mac AppStore). 
  • /Library/Audio - this is large folder, where I think GarageBand keeps its stuff. I don't use GB, so I don't need it backed up. 
  • /Library/Caches and ~/Library/Caches - caches. I don't want them backed up and they change often.
  • ~/Dropbox - it's where I have my Dropbox files. They're already backed up on Dropbox so, unless you don't trust them, you can exclude them. In case of a crash just resync your new installation. 
  • ~/Library/Mail Downloads - Mail.app downloads attachments here. You can redownload it, can't you?
  • ~/Music/iTunes/iTunes Media/Podcasts - podcasts can be downloaded again in case I'll want to listen to them again. 
  • /usr, /sbin, /bin, /private/var - system directories, you'll get them with reinstallation of the OSX anyway.
Now, some my specific stuff: 
  • If you're a Steam user, you can easily exclude the ~/Library/Application Support/Steam folder. With some games in here you can save some gigs of storage. Also it changes after every game... 
If you're doing iPhone development, like I do, there are some more things to exclude: 
  • /Developer is where the Xcode installation sits. You can redownload Xcode like any other app and reinstall it. 
  • ~/Library/Application Support/iPhone Simulator - exclude this if you don't need your installed on the simulator apps backed up. I don't. 
However, you want to keep your ~/Library/Developer folder backed up, I think. This is where the application archives go. And also here you can find the .DSYM files that you will need in order to symbolicate crash reports (if your apps crash sometimes. mine do). So in case of a Mac drive crashing, you might need it at some point. So I keep it backed up, even it takes some serious space (an app of 700MBs I'm working on now generates some real storage needs. But I don't want to risk loosing it). 

If you're interested to see which files take how much space (and possibly add something to the excludes list) you can use one of the solutions found here: See Which Files Time Machine Backed Up. I use Time Tracker. And it works. 

There are some important files I back up offsite, in case my home gets burned or hit by an asteroid. In the next post I describe some of the solutions available here and my experiences with them. 

27 maj 2010

Custom filtering in django admin

Just today I needed to add a filtering to a Django-based site that was using the admin interface for the backend job (I'm really lazy, so this is best I could do... and, django's admin is one of those great things in Django you just love as soon as you realise it's customizable).
Adding filter to django's list-view is simple: you just add a small line of code like this:

list_filter = ('location', )
to your ModelAdmin class.
Now if your model has a location field, you get this tiny, cute filter on the right side of the admin screen where you can select a location, and then you get only the objects that have this location. Easy, fast, ellegant.
My requirement was a bit different though. I can have many, many locations that none object is assigned to (in my case it's even a M2M relation, but it doesn't matter really), so selecting it for the filter would give me zero results. Zero, 0, null.
That'd be silly.
I didn't want the filter like this.
So my first try was to put a callable in the list_filter, not a field. Exception, it has to be a field.
A bit of googling and stackoverflowing showed me a hidden treasure: this snippet, an example of using not-documented FilterSpec in django.
Well, this snippet is even more complicated that what I needed. It appears that all I need is to create a FilterSpec class and insert it into the FilterSpec.filter_specs table (in front of any other, that's important!). Then tell the model to use this filter for the location field. Then - magic happens.

So, my class looks like this:

class RelatedFilterSpecWithResults(RelatedFilterSpec):

    def __init__(self, f, request, params, model, model_admin):
        super(RelatedFilterSpecWithResults, self).__init__(f, request, params, model, model_admin)
        self.lookup_choices = [(x.id, x) for x in models.Location.objects.exclude(inquiries = None)]

FilterSpec.filter_specs.insert(0, (lambda f: getattr(f, 'with_results', False), RelatedFilterSpecWithResults))
and then I only needed to add this:

location.with_results = True
to my model definition, where I had my location field defined.

7 maj 2010

The problem of online dates

In my last post I pointed out some problems with both online and offline dating. Now I'll try to focus on getting rid of them (well, that's what I do, get rid of problems, and you can try to hire me). So, the problem, in my very humble opinion, are the tables you need to fill on those dating sites as well as the fact that the workflow is really different there then the 'traditional' one, we're used to (thanks to our genetic memory, you know, and being raised up by people who didn't have Internet to date online).
How should the online dating look like to work, then? Because, you know, that's the point. To make it work.
First, you need to tell something about yourself. Something that can't be completed in 3 minutes, you need to invest some time, damnit, don't push all the effort on the dating site, after all you're the one that gets laid.
And something that won't be public. Noone would see this, trust me.
At least noone who'd be interested in you, or you'd be interested dating him/her.
The idea is to focus on matching rather then searching. The Internet doesn't really need more search engines, if you wanna search rather go here or here.
Ok, let's do matching. Some kind of machine should take all the information you've filled in, all information others filled in, and find a best-matching pairs. Don't ask me about this machine - I believe it should be human-powered (actually, if you're reading this post, and are interested in dating [either offline or online] with human... you should trust them; if you'd prefer a computer to match you, why the heck don't you date computers? they're great, smart and won't cheat on you).
So, the implementation of matching is out of topic for this post. What isn't is the process of fitting the matches. Because, you know, the date you'd have based on this match would suck. Believe me. They always do.
But knowing that your date sucked, the matching machine can propose you another possible date, better then the last one.
And that's the key to moving successful offline dating (which is also iterations-based) to online ones.


...to be continued.

Online vs offline dating

So, in today's world if you're single (or you're not, but you're an ass) you can either date online or offline.
Lets look into the differences between those 2.
Offline dating (some call it a 'traditional' dating, but traditionally you should just wait until your parents talk to the girl's parents and agree on the price...) is all about going out and meeting people. Then, when met, you talk to each other (usually), get to know each other, get obsessed with each other, fall in love, get married, get kids, get old and get grandchildren.
But, stop reading this and go out for 5 minutes. You'll see hundreds of people (if you don't, consider moving to NYC or some place like this, for the sake of reading this post). You don't expect to ask all them out, do you? The gotta be some way to decide which people you'd ask out and which you wouldn't even if your life depended on that.
There comes the 'first impression'. Or so they call it. It's basically the thing you can tell by looking at dozens of people and suddenly you think "oh my GOD, she's so hot. BOOM". Then you'd probably just run away because you'd know with such a hot girl you don't stand a chance, she's already taken and got this really cute boyfriend, who used to be a high-school football star and now he's a banker, makes lots of lots of money, so you just run away.
But if you actually come to her and try to talk you can find out this wonderful boyfriend of hers was just a jerk who left her for her best friend, so you can try... So you talk to this hot, really hot girl. And ask her out. And again. Only to find out that's she's so, so stupid you would have left her for her best friend too, but this best friend is already taken by the banker, damn.
So yeah. Here's the problem of first impressions: they usually are used to distinguish those worth talking to from all the rest - but also usually they fade away as soon as you know this person better; and they usually leave you stupid, standing there and bumping your head against the wall screaming "how could've I been so stupid, how, how, how?".
When it comes to online dating, the workflow is a bit of different.
You find the person on one of those stupid websites where you gotta fill tables with data like "5 things you like", "5 things you dislike", "how do you look like?". How do you fill those form? Put in some stupid stuff that would attract some other users to you - so there's virtually no way to think it's an honest description.
But OK, lets assume you've found someone who's just great online. You chat with her for days and nights, you get the actual impression of knowing her well. You know her sense of humour, her interests, what books she likes, how many times she saw Star Trek TOS, all that stuff that really matters. You both know your looks too, because you emailed your photos to each other. Then you decide to meet in person. And BOOM - you both get very disappointed. Why the heck? What just happened? This should be sooo great.
Well, admit it. You are visual. So is she. While you two were talking over the net, even before exchanging pics, you had her imagination based on her online profile. So had she. And remember, online profiles are never true. Or almost never.
The problem with online dating is, it's based on completely different workflow then offline ones.
Everything you know is based on those stupid tables/questionnaires everyone fills out. And never update. And never tells the truth there.
So what's the solution? Because, believe me, there is one... Well, the solution will come in the next post.