Older blog entries for maragato (starting at number 70)

Day 4 of my family linguistical experiment

A little context first. A little under four years ago I was relocated to Cordoba, Argentina for a stint at the local development center. My daughter Milena was two months old when she arrived her.

For the first year of her life, she was mostly unexposed to Spanish as my wife and I spoke Portuguese at home and TV was in English. When she was a little over one year old, she started staying at daycare as we wanted her to socialize and later because my wife went back to work. This exposed her to Spanish. So at this point, she was hearing Spanish, Portuguese, and English every day.

About a year later, she wasn’t speaking much yet and we inevitably compared her with other kids her age1, who were already saying many words, some already forming simple sentences. Our pediatrician told us many times that this was perfectly normal but finally said that if we wanted to, we could visit a child psychologist to calm ourselves. We did just that.

After a few sessions, the psychologist told us that we should probably not worry about some neurological problem2 because Milena did not exhibit any signs commonly associated with these problems. She did however told us that she was worried that my wife was working instead of staying home with her child. This led to two things: (1) my wife felt extremely guilty, while at the same time (2) we both felt that this was idiotic. It also nearly led to a third thing: we almost decided to stop going because it was not helping at all. But we still had two more sessions already scheduled and paid for so we decided to at least go to those.

My wife did not go to the next session as she was still angry at the psychologist for making her feel guilty. I don’t blame her. In this session, the psychologist told me that we should stop speaking Portuguese to our daughter. She said this was bad for her and that later she would have many years to learn other languages. In my head, I immediately dismissed this. But…

First-time parent that I am, I started saying a few simple things in Spanish to my daughter. Not whole phrases, but things that I knew she heard at the daycare. Stuff like “come here” and “very good!”, I’d say in Spanish. We went to our last session and the psychologist asked about it and I told her that I wasn’t really saying everything in Spanish but some things. She insisted that we should not expose Milena to anthing else. My wife argued that many said kids learn languages easily but we didn’t really push too hard: we would not get back.

We told our pediatrician about it. He said we were insane if we did that because he personally knew other foreign families whose children learned multiple languages and that is was perfectly normal for our daughter to take a little longer to start talking but that once she started, she’d speak both languages. We agreed. But…

Almost without thought, we continued saying some things in Spanish simply because Milena seemed to respond better. Saying “don’t!” in Spanish yielded better results than saying it in Portuguese, probably because she heard it often at daycare. This led us to saying more and more in Spanish. Coincidence or not, she started speaking more and more. In retrospect, we took the easy route. It wasn’t intentional but that’s what we did.

Now, she speaks well but only in Spanish. And we have been speaking only Spanish to her for almost two years. And this led to a point where I feel uncomfortable when talking to my own daughter. My Spanish is alright, but not perfect. And it does not feel natural to me. It comes out “artificial” for lack of a better word. Also, her grandparents don’t speak Spanish. Nor do her cousins: when they meed, there’s this “wall” between them. My nephews and niece don’t understand my daughter, which leads to frustration and lots of crying. Kids.

Well, a few days ago I decided to start an experiment. I now speak almost entirely Portuguese to her3.

I thought it would be tough and I am surprised that the toughest part so far has been ME. I got so used to speaking Spanish to her that I actually have to make an effort to remember to speak Portuguese. As for her, I am very surprised at how much she understands. I say fairly complex sentences and she gets them, whereas when I used to try those in Spanish, she wouldn’t. That’s obviously my Spanish’s fault, not hers.

She still responds mostly in Spanish but it is clear that she understands what I am saying. My wife and I speak Portuguese to each other, so she must have picked much from that. And being fair, I know she listens to pop Brazilian songs at daycare4 but still, I thought it would have been a little more difficult.

I’m happily surprised.

If you care to comment or suggest something, please do so in this Google+ thread. Thanks. And I’m @robteix at Twitter, so you can shout at me there as well.

  1. Big mistake, by the way. Don’t do that. We are stupid.
  2. Read, autism.
  3. I say “almost” because I still use Spanish for words that I know she doesn’t know yet. Like “pelota” (“ball”) and “rojo” (“red”). although I always make a point to tell her what the Portuguese word is so she’ll learn it.
  4. We catch her often singing songs from Brazil that she’d never listen to at our home — in fact just this morning she actually woke up singing “ah, se eu te pego, ai ai…” in bed, which merits a whole other post…

Syndicated 2013-01-29 14:47:34 from robteix dot com

Bad parents make me want to smash

We went to a hypermarket this morning for some needed groceries. While my wife went grocery shopping, I stayed with our daughter in the playground they have in there.

At some point, my daughter decided it was time to play in the little train they have there. An older kid was there but the little train has two seats so she went to the empty one and sat with the smile of the kind of joy only a 3 year-old feels when heading to enter a toy train. That joy was short lived as the kid decided he didn’t want to share and pushed her out.

I calmed her down and since the kid was already in the train before her, I decided it wasn’t worth it and just calmed her down. “Let’s go play over there and then we’ll come back later! Come on! Let’s go!” (Kids that age respond to enthusiasm.)

Fast forward to a bit later and the train was empty. My daughter decided it was a good time for a second try. She climbed aboard and started playing with the levers when the kid from before comes rushing and shouting “no no no no!” He then climbs aboard and throws her out. Let me make it clear I am talking about My. Little. Princess.

Oh boy.

“Hey,” I stared at him, “that’s not cool!” He must have been 8 or 9, my daughter is 3. He should know better by now.

He just replied, “It’s mine!”

“No, it’s not!” I said it back, the way adults talk to naughty children. “Where are your parents?”

Before he would answer, this lady comes and asks what’s going on. She’s obviously the kid’s mother. I tell her that he pushed my daughter out of the train and she’s looking at me like I’m speaking Russian or something1.

“Why can’t your child share it my son?” she asked, indignantly.

What?

“She tried to share it!” I protested. “Your son threw her out then. And now she was in there when your came and threw her out again!”

“How rude!” she told me, clearly meaning me and not her annoying little moster.

avengers-hulk-smashing-loki

She grabbed her kid while telling him that he couldn’t play because “some parents think the playground belong to their children” and other things.

I tell you, one of the toughest things I faced being a dad was at playgrounds: restraining myself.

  1. To be fair, I was a bit upset and I am sure I was mangling my Spanish, which isn’t very good to begin with.

Syndicated 2013-01-05 21:26:20 from robteix dot com

Linux Kernel Linked List Explained

I appreciate beautiful, readable code. And if someone were to ask me for an example of beautiful code, I’ve always had the answer ready: the linked list implementation in the Linux kernel.

The code is gorgeous in its simplicity, clarity, and amazing flexibility. If there’s ever a museum for code, this belongs there. It is a masterpiece of the craft.

I was just telling a friend about it while we talked about beautiful code and he found this piece that I share here: Linux Kernel Linked List Explained.

Syndicated 2013-01-04 20:13:22 from robteix dot com

Container changes in C++11

The recently approved C++11 standard brings a lot of welcome changes to C++ that modernize the language a little bit. Among the many changes, we find that containers have received some special love.

Initialization

C++ was long behind modern languages when it came to initializing containers. While you could do

int a[] = {1, 2, 3};

for simple arrays, things tended to get more verbose for more complex containers:

vector<string> v;
v.push_back("One");
v.push_back("Two");
v.push_back("Three");

C++11 has introduced an easier, simpler way to initialize this:

vector<string> v = {"One", "Two", "Three"};

The effects of the changes are even better for things like maps, which could get cumbersome quickly:

map<string, vector<string> > m;
vector<string> v1;
v1.push_back("A");
v1.push_back("B");
v1.push_back("C");

vector<string> v2;
v2.push_back("A");
v2.push_back("B");
v2.push_back("C");

m["One"] = v1;
m["Two"] = v2;

This can now be expressed as:

map<string, vector<string>> m = {{"One", {"A", "B", "C"}},
                                 {"Two", {"Z", "Y", "X"}}};

Much simpler and in line with most modern languages. As an aside, there’s another change in C++11 that would be easy to miss in the code above. The declaration

map<string, vector<string>> m;

was illegal until now due to >> always being evaluated to the right-shift operator; a space would always be required, like

map<string, vector<string> > m

No longer the case.

Iterating

Iterating through containers was also inconvenient. Iterating the simple vector v above:

for (vector<string>::iterator i = v.begin();
     i != v.end(); i++)
    cout << i << endl;

Modern languages have long had some foreach equivalent that allowed us easier ways to iterate through these structures without having to explicitly worry about iterators types. C++11 is finally catching up:

for (string s : v)
    cout << s << endl;

As well, C++11 brings in a new keyword, auto, that will evaluate to a type in compile-type. So instead of

for (map<string, vector<string> >::iterator i = m.begin();
     i != m.end(); i++) {

we can now write

for (auto i = m.begin(); i != m.end(); i++) {

and auto will evaluate to map<string, vector<string>>::iterator.

Combining these changes, we move from the horrendous

for (map<string, vector<string> >::iterator i = m.begin();
     i != m.end(); i++)
    for (vector<string>::iterator j = i->second.begin();
         j != i->second.end(); j++)
        cout << i->first << ': ' << *j << endl;

to the much simpler

for (auto i : m)
    for (auto j : i.second)
        cout << i.first << ': ' << j << endl;

Not bad.

C++11 support varies a lot from compiler to compiler, but all of the changes above are already supported in the latest versions of GCC, LLVM, and MSVC compilers.

Syndicated 2012-12-15 14:41:36 from robteix dot com

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) {
        this.resources.add(resource);
    }

    public void printSlips() {

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

                System.out.println(resource.name());
                System.out.println(resource.salary());
            }
        }
    }
}

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() {
        super();
    }

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

    public void add(Resource resource) {
        this.resources.add(resource);
    }

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

        while(iterator.hasNext()) {
            block.evaluate(iterator.next());
        }

    }

    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)) {
                resourceOrderedCollection.add(resource);
            }
        }

        return resourceOrderedCollection;
    }
}

public class Department {

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

    public void addResource(Resource resource) {
        this.resources.add(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

20121111-121454.jpg

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.”

LOL

“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

61 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!