The power of binary operations.

The following code:

Selec All Code:
NSString *resolvedSource = oneResolved ? oneSource : otherSource;
if ([self projectSourceIsPortrait:resolvedSource]) {
    if (oneResolved) {
        oneTile.landscape.source = otherSource;
    } else {
        oneTile.portrait.source = otherSource;
    }
} else {
    if (oneResolved) {
        oneTile.portrait.source = otherSource;
    } else {
        oneTile.landscape.source = otherSource;
    }
}

can with proper use of binary operations turn into 8 lines (down from 14):

Selec All Code:
NSString *resolvedSource = oneResolved ? oneSource : otherSource;
BOOL setPortrait = oneResolved;
setPortrait ^= [self projectSourceIsPortrait:resolvedSource];
if (setPortrait) {
    oneTile.portrait.source = otherSource;
} else {
    oneTile.landscape.source = otherSource;
}

You can of course make the setPortrait bool a one-liner too, as in

Selec All Code:
BOOL setPortrait = oneResolved ^ [self projectSourceIsPortrait:resolvedSource];

dropping you down to 7 lines of code. The XOR operator is more useful than it’s being given credit for. :)

Posted in General | Leave a comment

Right.

Posted in General | Leave a comment

Bleh.

Yep yep, Swedish water is so fucking wonderfully clean. We’re so god damned proud of it it makes you vomit.

 

Posted in Sweden | Tagged , , | 4 Comments

Can’t think of a more sophisticated way to get kicked out.

In the Console for my iPad, I got the following just as my app was killed for using too much memory:

<?xml version=”1.0″ encoding=”UTF-8″?><!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”><plist version=”1.0″><dict> <key>Label</key> <string>syslog_relay</string> <key>ProtocolVersion</key> <string>2</string> <key>Request</key> <string>Goodbye</string></dict></plist>

Despite the annoyance of memory issues, I couldn’t help giggle at that one. “Goodbye”! Haha! I’ve never been kicked out in as extravagant a fashion as this.

Posted in General | Leave a comment

Privacy

As some of you know, I moved to a new apartment in January, and with that obviously came a bunch of subscriptions (as in, “electricity bill” kind of subscriptions). I had the option to choose between a bunch of different electricity companies but ended up just going with the default one (E.ON).

After a few months I got a phone call from E.ON. where they basically offered me a better than the default deal, which I accepted, and then today the contract arrived. Now… not a lot of people read these, right? I tend to give them a skim at least, to see if something insane appears and sometimes I hit the jackpot.

“The personal details of you that we have obtained are necessary to accomplish our part of this agreement and to accomodate your needs as a customer. Your name and address may also be used for marketing by E.ON. as well as by companies with which E.ON. is cooperating. Your personal information may also be used in educational purposes.” (bold emphasis mine)

So uh… not thinking there was much hope, I still decided to just email them,

“Hi,

According to the contract you sent to my home, “(the above quote)”

I do NOT want you to use my personal information for marketing, and I most definitely don’t want you to give it out to other companies.

Sincerely,

-Kalle Alm (my personal id number).”

Within an hour I got a response which to my surprise went:

“Hi,

Thanks for your email.

We have registered that you do not want us to use your personal information for marketing purposes.

Please contact us again [blabla].”

I didn’t think it’d be that easy, but there you have it. Summary: read through your contracts! You might end up with a company like E.ON. who thinks people are too lazy to read through this “boring” stuff!

Posted in Privacy | Tagged , , , , | Leave a comment

Honestly…

I hate to gripe just as the next guy, but seriously… going to the U.S. is just becoming more and more of a pain in the ass as time goes on. I’m going to S.F. to attend WWDC 2011, which I’m looking forward to. Except it’s the U.S. I’m going to. The land of laying down the hate on foreign visitors.

Last year when I went to the U.S., I had the unexpected fortune of encountering a customs officer who actually treated me like a living object. I even told her so.

“This is my first time being treated like a person, you know. Going through these customs control thingies.”, says I.
“Oh… I’m sorry?”, says she, with a guilty grin.

Most of my trips to the states, I’ve over-thought this situation quite a bit. I’ve reasoned erroneously that these guys probably have a lot of tired and annoyed people going through, so I should at least make an effort and smile. That smile has put me inside rooms with mexicans and other dirty peoples (note the sarcasm, by the way) for 3-4 hours at a time. That smile, to me a way to say, “I know you’re just doing your job, but I don’t hate on you for it,” was to them a sign of suspicion.

So a few years ago I had enough. I knew I was going to be treated like excrement glaced with vomit, so I gave them exact, precise honesty. Frowning, grunting out replies, staring at them fully expecting the treatment I was surely going to be having, and I had it every time but that one time last year. And amusingly, I’ve not been questioned extensively or brought to any rooms with mexicans since.

Then came ESTA. Going to a country which is a part of the Schenger agreement (I think that’s the one) lets you, without a visa, enter the country for up to 90 days. Except someone in the states decided this was awfully unsafe, so they put up ESTA, a web site with seemingly no meaning whatsoever* , where you are asked questions you will be asked again, later.

(* except to deny you entry BEFORE you fly all the way over there, which I guess is a good thing — I’ve heard of people being sent all the way back home)

Regardless, what are these questions then, you might ask? Anyone who’s gone to the states has no doubt (whilst giggling quietly to themselves) answered these absolutely ridiculous questions.

I mean… good thing I said No to all of those, right! Phew. Just look at (B), for example. If I was — and to any U.S. officials swinging by to see why the ESTA content are being published on my blog, I might assert that I am not — planning on “engaging in criminal or immoral activities”, I’m sure I’d be tempted for at least a second to answer Yes, honest as I am.

The big dump of excrement in my eye though is that this ridiculous form underwent a change as of March this year.

It now charges you $14 per application.

So not only am I forced to waste my time on the above bullshit, but I’m charged to do so.

Posted in General | Tagged , , , , , | 1 Comment

Worst week ever.

Monday: exam, Computer Science — went well, I thought.

Wednesday: exam, Linear Algebra and Geometry — uh, yeah. That was a waste of effort.

Friday: exam, Networks and Communication — at least this one went reasonably well.

Monday’s exam I didn’t study for, at all. I’d gone through the whole course like a breeze, learning lots of interesting little tidbits (e.g. the assembly language!), and mostly enjoying myself, which is why I felt that I could walk in there and do the exam like it was nothing. Turns out I was wrong, as I saw the “solution proposal” they put up (I’d done a bunch of errors, not read text properly, etc). I think I’ll pass, but no flying colors here.

Wednesday’s exam was the one I *did* study for. A lot. But because of ass-hole teachers who won’t bother answering emails, I didn’t get to enter the course until 2 weeks into it, and since I didn’t get the go ahead until that late, it took about another week before I had the book, which resulted in constant lagging behind. The intention was to sit down with it a weekend and study like a fiend to catch up with the others, but that just never happened. Over this weekend and Monday-Tuesday, I studied like a fool, but in the end I had to skim through something like 100 pages worth of stuff, skipping over the actual problem sections each time. I’ve developed an unprecedented hatred for Howard Anton, the author of the book, for his unrivaled incompetence in pedagogy.

Friday’s exam there’s not much to say about. I didn’t study anything up until the last day (i.e. yesterday), and the studying I did was only reading old exams. No flying color passing here either, but I’d be surprised if I didn’t pass.

At least it’s all over. For now.

Posted in General | Leave a comment

iPhone Personal Hotspot

The next version of iOS (iPhone OS), 4.3, features a thing that android phones have had for awhile now (and jailbroken iPhones) — Personal Hotspot. I.e. the ability to set up a WiFi station on your iPhone and surf the net from a computer or such.

A few hours ago, my network at home went down so I found a use for that personal hotspot feature sooner than I’d imagined (I got the beta of the iOS release as a developer). It’s… fast. I’m actually not noticing a difference in the speed web pages are loading. And me and my wife are both using my iPhone 4 to surf.

The battery is plummeting though but I’m in the house after all. Just need to plug it in, but was interested in seeing just how much pressure this’d put on the little thing.

Still, way cool.

Posted in Hardware | Tagged , , , , , , , | 2 Comments

Managed-by-Xcode provisioning profile that expired.

Any iOS developer has learned to appreciate the cruelties and hardships of life the moment they begun trying to make sense of Apple’s “unique” provisioning profile system. In short, it blows donkey-brains. That said, here’s a bit of info for you in case you run into the following scenario:

You are using a “Team Provisioning Profile” and it expired. You went to renew and download it, and noted “Managed by Xcode” and the “Renew” button was grayed out.

The solution: delete the profile from Organizer in Xcode, then at the top click “Refresh” (right by “Automatic Device Provisioning”). Organizer will fetch a new provisioning profile with a new expiration date.

Intuitive indeed.

Posted in Work | Tagged , , , , , , , | 3 Comments

Thanks for the privacy, Apple.

A few weeks ago I was in the laundry room doing, you guessed it, laundry. The machine had 5-6 minutes left so I decided to just sit and wait, while fiddling with my iPhone.

Bored as I was, I typed in “sex” in the search and got a bunch of random looking results. I downloaded one, looked at it, noted (with no surprise) that it was retarded and then the machine beeped and I thought nothing more of it.

Fastforward a bit. Here you see me plugging my iPhone into my computer. It syncs.

Fastforward some more. Here you see me finding that app later. I delete it from the phone, thinking “phew, good thing I didn’t leave that around in case someone found it. How embarrasing.”

Fastforward again. Here I’m plugging the iPad into the computer. It syncs.

Fastforward a final time. Here’s my 12 year old niece playing, as she always does whenever she’s visiting, with my iPad.

And then later that day, I look at the first app page and what do I see? Yeah. iTunes synced that app in from my iPhone and out to my iPad. It’s a setting that I have control over, but geez, where are the privacy features on these bloody things? Where can I “hide” stuff I don’t want my 12 year old niece to stumble on?

Sigh. And now you guys know I downloaded a smut app. But the fact my 12 year old niece might have seen it is by far worse. Much, much worse. Ugh.

Posted in Stupid | Tagged , , , , , | Leave a comment