Older blog entries for maragato (starting at number 66)

FOR is evil or something

Have you ever wondered how FORs impact your code? How they are limiting your design and more important how they are transforming your code into an amount of lines without any human meaning?

How can you not want to read an article that starts like that? I had to steal the intro from the original. Seriously, I have used FOR since I learned BASIC back in the day. I never thought about how it was limiting my design. I. Must. Learn. How.

The article I am referring to is, Avoiding FORs – Anti-If Campaign. Eager learner I, I could not not read it.

After the resplendent intro, Avoiding FOR goes on to show “how to transform a simple example of a for […], to something more readable and well designed.”

It takes this unreadable piece of code — that I now recognize as unreadable:

public class Department {

    private List resources = new ArrayList();

    public void addResource(Resource resource) {

    public void printSlips() {

        for (Resource resource : resources) {
            if(resource.lastContract().deadline().after(new Date())) {


My eyes hurt already. Thankfully the author transforms the aberration above into this clean, much more readable snippet:

public class ResourceOrderedCollection {
        private Collection<Resource> resources = new ArrayList<Resource>();

    public ResourceOrderedCollection() {

    public ResourceOrderedCollection(Collection<Resource> resources) {
        this.resources = resources;

    public void add(Resource resource) {

    public void forEachDo(Block block) {
        Iterator<Resource> iterator = resources.iterator();

        while(iterator.hasNext()) {


    public ResourceOrderedCollection select(Predicate predicate) {

        ResourceOrderedCollection resourceOrderedCollection = new ResourceOrderedCollection();

        Iterator<Resource> iterator = resources.iterator();

        while(iterator.hasNext()) {
            Resource resource = iterator.next();
            if(predicate.is(resource)) {

        return resourceOrderedCollection;

public class Department {

    private List<Resource> resources = new ArrayList<Resource>();

    public void addResource(Resource resource) {

    public void printSlips() {
        new ResourceOrderedCollection(this.resources).select(new InForcePredicate()).forEachDo(new PrintSlip());


Wait, what? Is this an Onion article?

Snarky Mode Off.

I understand what the author wanted to do, but really, the example used is so off the left field that it’s not even funny.

Syndicated 2012-11-19 13:31:16 from robteix dot com

Missus Lady Wife’s bday


Wife’s birthday translates into dad-daughter’s day out as my wife gets a day-off from us :)

Syndicated 2012-11-11 15:07:51 from robteix dot com

All those black people…

I had a talk with my landlady.

Prostest against the Argentine government in Buenos Aires

There had been another set of monster protests against the government in Argentina and she was talking about the situation in her country.

As usual, she scolded me for leaving Brazil and coming here.

As usual, I tried to stay out of it saying I don’t really follow the news.

“And also,” I explained, “Brazil isn’t that much better, you know?”

“Ah, but you are so much more organized,” she continued.

“We were lucky with the last few presidencies,” I conceded.

“That wasn’t luck,” she educated me. “You know how to vote over there.”


“We have too much corruption,” I continued. “And crime. We’ve got too much violence!”

And then she said something I heard before in Argentina.

“Ah, yes,” she permitted sympathetically. “You have all those black people…”

She must have seen my face because she said “well, I don’t know, of course.”

“That’s not the problem, you know,” I said. “When I was kidnapped, none of the men were blacks. That really isn’t how it works over there.”

And we changed the subject.

That’s not the first time I hear from someone here the same argument that Brazil’s problems are somehow a result of “those black people” but it stills throws me off, every time.

Syndicated 2012-11-10 21:39:16 from robteix dot com

Quote of the Day

An idiot with a PhD is still an idiot

Syndicated 2012-11-10 11:57:25 from robteix dot com

Rolling out your own Fusion Drive with the recovery partition

disk utility showing Fusion Drive

My Macbook Pro has two disks, an HDD and an SSD, each of 240GB or so. With the details of Apple’s Fusion Drive coming out I decided to do what any reasonable geek would do to their production computer: I’ve decided to implement my own untested, highly experimental and barely understood Fusion Drive.

One of the things that initially put me off doing this was that according to the 3,471,918 tutorials that have popped up in the last 10 minutes would cause me to lose my Mountain Lion recovery partition because these partitions are not supported in a Fusion drive. Turns out this is not exactly true.

Fusion Drive is just a marketing term for a what essentially is a CoreStorage logical volume spanning an SSD and an HDD. And although you cannot have the recovery partition inside a CS logical volume, it doesn’t mean you can’t have both a recovery partition and a Fusion Drive at the same time. It’s all in the diskutil man page, by the way:

Create a CoreStorage logical volume group. The disks specified will become the (initial) set of physical volumes; more than one may be specified. You can specify partitions (which will be re-typed to be Apple_CoreStorage) or whole-disks (which will be partitioned as GPT and will contain an Apple_CoreStorage partition). The resulting LVG UUID can then be used with createVolume below. All existing data on the drive(s) will be lost. Ownership of the affected disk is required.

What matters is what’s in bold above: we’re not limited to using whole disks. So here’s what I did.

I rebooted my system and held the option key so I could select my recovery partition as the start up disk. Once the OSX recovery started up, I launched a terminal to do the dirty work.

  diskutil list

From this I noted two things: (a) the main SSD partition (the one holding my OSX and that sited by my recovery partition) and (b) the disk name of my HDD. They were respectively disk0s2 and disk1 in my case, but they’ll very likely be different for you. Then the magic begins.

  diskutil cs create "Fusion Drive" disk0s2 disk1

(For crying out loud, you need to change disk0s2 and disk1 for whatever makes sense on your system!)

That created the coreStorage logical volume. Then I listed it all again to note what the new logical volume UUID was.

  diskutil list

The UUID is a long number identifier like F47AC10B-58CC-4372-A567-0E02B2C3D479. You’ll need that one next to actually create the volume where you’ll be installing your system.

  diskutil coreStorage createVolume F47AC10B-58CC-4372-A567-0E02B2C3D479 jhfs+ "Macbook FD" 100%

The command above will create a volume named “Macbook FD” using 100% of the logical volume we had created earlier.

I then restored my Time Machine backup and that’s it.

Update: Note that after this process, the Recovery partition will still be present and things that require it (such as Find My Mac) will work fine. Some people correctly pointed out, however, that you can no longer boot from the recovery partition by using the menu from holding ⌥ (option) during boot. I’m not sure why that is, but fear not, it will still boot normally from pressing R (command + R).

Syndicated 2012-11-09 11:18:34 from robteix dot com

Not a-ok

I have a little confession to make: our family is going through a rough patch. Both my wife and I are having problems. No, not between us. And both are experiencing very different sorts of problems. But the happening-at-the-same-time complicates the one-supports-the-other thing.

And to compound to that, I have been sick.

As I sat in the waiting room at the hospital the other day, waiting for some exams, I felt like this is one of the worst times of my life. I feel tired, unmotivated, unappreciated, and generally unhappy. And fucking hopeless. That’s the worst part, I suppose.

I also have been distancing myself from friends lately. Ostensibly to avoid distractions in a time where I am having to give all and a bit more to a project I do not believe in. Truth be told, I just don’t feel like small talk but I also don’t want bring others down to my Dark Hole of Misery. And so I’m trying to keep some distance.

I feel lost. I look at my friends and how they all seem to have it all figured out already. I’m still trying to figure out who the fuck I am. I was so sure when I was younger. I was so fucking good at what I did. Now? I just don’t know anymore. I feel unhappy.

I know some people who will be So. Fucking. Happy. reading the paragraph above. This one’s for free for you guys.

But not all is bad news. I actually got some good news last night. I can’t tell the details although I know some of you know exactly what this is about. Anyway, I now have a set date for it and it’s in under six months from now.

I’m actually confident that this will make it all better somehow. Just have to wait.

Sorry for the downer, but I felt like writing something.

Syndicated 2012-11-08 17:48:39 from robteix dot com

Shouldn’t be much of a surprise to anyone…

Shouldn't be much of a surprise to anyone…

Kaspersky: Mac security is '10 years behind Microsoft'

In an interview, the security firm's CEO says Apple has a lot more malware coming its way, and that it's not putting enough resources into protecting users. Read this blog post by Josh Lowensohn on Ap…

Syndicated 2012-04-26 20:33:10 from ~robteix

The article points to a huge resource library…

The article points to a huge resource library on the software used. But the really cool part is how they actually stored the software. LOL Memory FTW

Source code for Apollo and Gemini programs

An extensive collection gathered from all over the internet of the source code and documentation for NASA's Apollo and Gemini prog

Syndicated 2012-04-26 15:58:13 from ~robteix

Reshared post from Sang Lam

Heck! It seems like just yesterday I was anxiously awaiting version 4!

Sang Lam originally shared this post:

Firefox 12 already? Seems like just yesterday I installed Firefox 11. #smh

Firefox 12 released with UAC-less update system on Windows

Mozilla has released Firefox 12. The new version of the open source Web browser introduces a new update service for Windows that allows the browser to perform updates without user intervention. Full s…

Syndicated 2012-04-25 16:38:17 from ~robteix

Reshared post from Amanda Patterson

I love these :)

Amanda Patterson originally shared this post:

12 Remarkable Quotes About Writing

1. “Substitute ‘damn’ every time you’re inclined to write ‘very’; your editor will delete it and the writing will be just as it should be.” ~ Mark Twain

2. “If writing seems hard, it’s because it is hard. It’s one of the hardest things people do.” ~ William Zinsser

3. “Writing well means never having to say, ‘I guess you had to be there.’ ” ~ Jef Mallett

4. “Writing gives you the illusion of control, and then you realize it’s just an illusion, that people are going to bring their own stuff into it.” ~ David Sedaris

5. “There’s nothing to writing. All you do is sit down at a typewriter and open a vein.” ~ Red Smith

6. “Writing is a socially acceptable form of schizophrenia.” ~ E.L. Doctorow

7. “I’m not a very good writer, but I’m an excellent rewriter.” ~ James Michener

8. “Easy reading is damn hard writing.” ~ Nathaniel Hawthorne

9. “If my doctor told me I had only six minutes to live, I wouldn’t brood. I’d type a little faster.” ~ Isaac Asimov

10. “The road to hell is paved with adverbs.” ~ Stephen King

11. “Ink and paper are sometimes passionate lovers, oftentimes brother and sister, and occasionally mortal enemies.” ~ Terri Guillemets

12. “Write drunk, edit sober.” ~ Ernest Hemingway

Quotes: 12most.com/2012/04/11/12-worth-documenting-writing-quotes/Image: etsy.com/listing/65242328/ernest-hemingway-art-prints-posters

Syndicated 2012-04-25 16:27:21 from ~robteix

57 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!