biappi.nnva.org

Biappi's web log

Welcome to my blog, i'll try to keep it interesting to read! Please feel free comment on any post, i'd really appreciate that!

Twitter + Quicksilver = TwitterSilver!

3 september, no comments, mind to share your impressions?

I'm a HUGE fan of Quicksilver, i simply cannot use a pc that lacks it. Right now, i'm using for few things, app launcher, iTunes control ("pp" FTW), and to browse my contacts when i need to send an email.

On the other hand, i'm not that much an user of Twitter, but i know some really cool people there and once in a while i check it out. I tought, maybe i'll use it a bit more if i can use it the way i use the rest of software, like when the IM support was working, for example.

So, as an excuse to start editing some code, i brushed up my old post on Python, plugins and Adium and started VIM, my console-editor of choice (the other beings TextWrangler and Xcode).

Turns out that Quicksilver is an half-dead project, and docs is really non-existant, but i managed to found some good posts about Quicksilver plugins.

That, and what i've learnt from my previous approach, helped me to bake in roughly an hour TwitterSilver, the Quicksilver Plugin that Tweets!

Of course you can download and use it, and, surprise, i'm using it to introduce my brand new code repository at Google Code, where you can find lots of non working vapourware!

To get started, simply do in a Terminal window:

Xanthia:~ willy$ svn checkout http://biappi-repo.googlecode.com/svn/trunk/TwitterSilver TwitterSilver
[...]
Xanthia:~ willy$ cd TwitterSilver/
Xanthia:TwitterSilver willy$ python setup.py py2app
[... lots of input ...]
Xanthia:TwitterSilver willy$ echo "USERNAME PASSWORD" > ~/Library/Preferences/org.nnva.biappi.TwitterSilver 
Xanthia:TwitterSilver willy$ open dist/TwitterSilver.qsplugin/

then, open Quicksilver, press "." to input some text, then select "Send Tweet to Twitter" action!

I hope this can be useful to someone =), if you're using it, let me know! =).

Tags for this post: Coding, Python

Custom Icon For Source Code Directory

2 september, no comments, mind to share your impressions?

When i look at my home directory in Finder, there was something that stroked my eyes: my Project directory, the one in which i use to put all my code, is the only one without a custom icon.

Today i was in an harddisk-cleaning mood, and i found the skills to do a (pretty bad) custom icon for that directory!

I tried to find a tutorial, to "emboss" some custom graphic into the standard Leopard folder, but the only one i found was using a Photoshop template and it did not explain nothing but "drag your bitmapped image to this layer, the template will do the stuff".

I've considered the option to download a demo copy of Photoshop to do the trick, but it was an huge download, really overkill for what i wanted to do, besides Adobe has this bad reputation with installer i didn't even wanted to try.

Instead i tried to reccall all the Pixelcorps free tutorials i've watched, and fired up The Gimp.

It turned out the process of creating this style of icons is really simple:

  1. create a layer with the "base" folder
  2. duplicate it, and the copy a bit using tools such as Luminosity and Contrast
  3. create a one-channel mask with the graphics you want to "etch" on the folder
  4. make a bump map of the light folder with the mask
  5. use the mask as the alpha channel for the dark folder

easy, isn't it?

However, just to prove my mad gimp-fu, here is the screenshoot of my new home directory:

My home directory with the new icon

and, since i'm really generous =), you can download the icon and use it as you please!.

Tags for this post: Apple, Leopard

I'm Really That Crazy

1 september, no comments, mind to share your impressions?

What you can do with no Internet connection, a compiler, and lots of spare time on vacation?

Yup, I managed to write a small and buggy blog editor for updating my blog via Zoe, my little iPhone!

This is, in fact, the first post i'm writing with this editor.

It uses the MetaBlog interface, so it would even work with other blog engines, but I do not trust my coding skills =).

However, I don't know what to do with this piece of code, maybe I'll refine it a little bit and put it as a freebie on the App Store, we'll see...

If that do not violate the FUCKING NDA, I can even think to publish the sources!

Anyway, back to coding =).

Ah, just to be clear 'bout that. FUCKING NDA.

Tags for this post: Coding, Apple, iPhone

My Google Interview Experience

25 july, 4 comments, mind to share your impressions?

It's crazy!

A while ago, circa january 2008, i was coming back home drank as hell. Before going to bed, i've peeked at the email client and there was an email labeled "Google Engineering".

Clearly i've drank that much to have hallucinations.

So, after a good sleep, i came back at my terminal, and the mail was still here!!

A Google recruiter actually contacted me to send a C.V.!! I couldn't miss that occasion and for a weekend i was the happier person in the earth.

It turned out that they wanted only graduated persons, and while i've spent 6 years in two universities, i still don't have my fscking degree. They asked me an estimate on my graduation (which i missed, of course..) and to my GREAT surprise, they recalled me!!!

So yesterday, after some days of chasing, i got the screening call from the recruiter.

I was nervous as hell, and after the WWDC experience, i do not trust my spoken english anymore, so just to loose my nerves i've drank a beer =), i don't know if it helped, tought.

I had to choose from three main topics, i don't remember the first, maybe system administration, TCP/IP stuff, and general computer science questions.

I choose the last one, feeling like a guest in a TV quiz game.

The questions started, to my surprise they was all really easy, maybe because it was the non-technical interview, by the was that's more or less how the conversation felt like.

What's the quicksort complexity? Quicksort? Easy one: that's a comparison sort, so it have its O(nlogn) and Theta(n squared). She liked the fast response i gave, or at least that's what i'd like to think. =) (i was so nervous my hands was shaking)

Order from quicker to slower the following: context switch, memory write, disk seek, register read. (Thinking...) What's that? I'm really in "Who wants to be a millionarie? (Speaking) Ok, of course register read, then memory write, now i'm in doubt between context switch and disk seek, it should depend on machine architecture, but i'd say first context switch then disk seek. I hope that last note was appreciated! (despite i did know the answer, my voice was flickering)

Algorithms: you've a 10000 int array, you've to write a fast algorithm to count all the bits set to 1, and you've got unlimited RAM Oh... let'see the first algo i can think of is a linear search counting the bits of one integer using 32 bitmasks, which is constant time... i'd say you can go faster, but i can't think of a way right now. (shaking, flickering voice, soaked in sweat).

How you'd use the hint that you've got how many ram you'd like? Uh, i think i'd broke the integer some way, putting the pieces in some known buckets and count them... (ockay i reckon that was really non sense but she stopped me anyway...)

Now this is an hard question choose your best language... Argh... C, C++, Python? Err.. C! What is a void *? HEAJ? And that's an hard question, it's a pointer to an unkown type!!

Ah, by the way, our answer to that algorithm was: you divide the int by two bytes, and you made a lookup table to count byte per byte, so your answer was indeed on the right track!!

Wow, right now i'm pretty happy with this talk... I've answered correctly in basically no time. Now i know that those was really basic questions, still they managed to tickle my reality distortion field! =). (mine is not triggered only by Steve).

Now i'm waiting a written questionnaire, then i'll have to do two highly technical 45 minutes phone talks, and if i'll prove to be good enough for the Big G, i'll get an interview in person!! WOO

I don't know what will happen... But so far, i'm really happy!!! Even if they'll dump me, after all i still have no BS, being contacted by Google, and getting to have even the screening interview for me is like being in heaven =).

Thanks Alice!

Tags for this post: Personal, The Future, Google

Damn, i'm looking good

17 july, 3 comments, mind to share your impressions?

Update: here is the whole article appeared today on Nova 24, which is a spinoff of Il Sole 24 Ore.

Impressive... my mugshot appeared on the national buisness newspaper!!!

Sole 24 Hours

Tags for this post: Personal, iPhone

Feed Couch, Revisited

4 july, no comments, mind to share your impressions?

Remember my feed reader?

Well, i had to add more eye-candiness to get my grade, and it seems Cisternis' liked it, i got 30/30 cum laude =)

This is a screencast:

The concept is quite simple, you get the last 5 entries of the Safari's subscribed feeds, and you navigate them with the Apple Remote.

The code has a little... ehm.. "shortcut" i don't like at all, but i had to do it really fast, and i didnt want to refactor the code 30 minutes before the exam, but...

You can downoad Feed Couch Source Code

It includes the MIT-Licensed Remote Control Wrapper by Martin Kahr. Thanks, Martin!

Tags for this post: Coding, Safari, Core Animation

First post from Mars Edit!

25 june, only one comment, mind to share your impressions?

I wanted to try this for a long time, but i never had the willings to implement the protocol bits. Don't know how, but i'm in a hack-my-blog mood, so here we are...

I've implemented a partially working Meta Weblog API that allows me to use a blogging client like Mars Edit to write my blog posts!

Working with Python is really a pleasure...

Right now my implementation lacks a proper authentication, i just check my credentials as "magic numbers", edit and tag support.

I don't think i'll ever address the auth thing, but if i'm in the mood of completing this thing, at least to allow basic post editing, i'll release the script...

Well, don't know if it will be useful to anyone, since it's tied to my model classes, but maybe it will be a good starting point, or an example, i don't know.

Of course, if you want it right now, just shout in the comments =).

Tags for this post: The Future, Coding, Django

Website Redesign!

22 june, 2 comments, mind to share your impressions?

When someone has to study, you know, he will find a great number of excuses to slaking off in peace with his consciousness.

That's why this site sports a whole new design. It's more flexible, so code should be more readable, and i think it'll scale well with non-blog kind of content.

Next steps: collect all the mini-scripts and things i've hidden in the Net and collect 'em here.

Yeah, something to do in the hot days here in Calabria!

Tags for this post: Personal, bla-bla

On Memory Management And Garbage Collection

19 june, no comments, mind to share your impressions?

At WWDC i've had the chance to meet many different kinds of developers: the "shareware student", the indie "bigs", the employee of big companies, even some IT guys.

For me, with the little experience i have, it was a big chance to relate with others, and get inspired. I've realized that living in a rich environment stimulates you, it makes you more productive by putting you in "the right mood" to actually start and getting some things done!

Talking to some people, conversation naturally shifts to the tools we use, as computer programmers, developers and scientists. And as anyone knows, those topics are a rough equivalent of religion. Church of VIM, church of Emacs, the Ruby vs Emacs... you name it!

After the light fights of text editors, the turn of programming languages arrived, and i got really "ignited" when i've heard something in the line of "i hate objective-c because it lacks garbage collection, objective-c 2.0 is muuuuuuuuuuuuuuuuuch better.. why i have to manage my memory!".

Now, let me state that i love GC and i use it actively, BUT as i say, "as a programmer you've got to know every other byte in the address space your application run".

Now i really was the guy from the outer space, actually liking all that retain and release methods, malloc() and free() functions... i really had to be some strange, uncommon alien.

But now, let me exapand a little on this, which i meant to be this post's topic.

Of course you'll use GC, automatic memory managment and a whole set of tools to make your job easier and less error-prone, but you do not have to forget what you're actually doing, you've to carefully know what choices you've made, yourself or by using a determined set of tools.

A computer really is nothing more than a thing that computes things on memory, just that. Every other piece of software or hardware is just something that can be seen as piece of memory or piece of "something that computes".

The monitor you see this website is basically a matrix of pixel in memory, the mouse and keyboard are really a small number between other 2^32, disks, something more, but substance doesn't change that much.

It's not by chance that the kernel of an operating system simply is nothing but a manager for the computational resources - the scheduling part - and the memory resources - the virtual memory, paging on disk, et cetera.

Managing computational resources used to be simple, you take the processor do some work, then kindly release it so other can use it.

We know this is changing with time: we're heading at multicore machines, and bla bla bla.. all things you already know if you're not living inside a bunker.

Scaling used to be very easy too... just wait til intel or amd build a faster cpu and your program run faster.

Memory is really another beast.

First thing first, memory costs. Because of that cost we've designed a memory hierarchy, exploiting the fact that memory the slower is, the cheaper is, and usually at minus cost per bytes.

Because of that hierarchy we have introduced a bit of time delays in transferring chunks of memory between layers, if you do opengl stuff just look at texture management.

Sometimes when programming it's useful to have in mind that memory caching *does* affect performance. One notable example, the radix sort: despite being linear, it's execution time is often greater than comparison sorts, with their O(nlogn) scores. [The Influence of Caches on the Performance of Sorting - LaMarca and Ladner]

Translation: because of caching, a program theoretically blazing fast, is actually slower than a program theoretically fast, but not blazing.

Then, as a consequence of memory being costly, memory is small. And already packed up with code and resources. And our dataset. But that's an abstraction, in reality we have that our memory is shared between all the other programs, and we have to play nicely on that!

In particular, allocation and deallocation of memory are operations that take some time to do, so it's better to do it well.

Even if you're using garbage collection, you need to know what it does, and how. Like any other tool you have to know its strenght and weakness in order to master it.

Tags for this post: bla-bla, Coding

Uncompress Mac Os X Packages Without Pacifist

15 june, no comments, mind to share your impressions?

This has been really an awesome week, i've met really nice persons and all the WWDC's sessions were really awesome, even if some were really basic... you know for all the newbies that are jumping in the whole iPhone thing.

Right now i'm in the plane from SFO to JFK playing around with my copy of the awesome Snow Leopard Developer Preview, but do not worry or get too excited, you know all the NDA things.

Instead, i want to talk you about Installer Packages.

I've not yet installed 10.6 but i'm on a really, really long flight and, guess what, really bored, but i don't want to install a whole OS running on batteries, but however i slapped the cd in the Xantia's drive, and i just realized what i had to do: i cannot install the os, at least let's see the documentation of the magnificent new features, [REDACTED] someone might say =).

Then, of course, the problem: my copy of Pacifist kept crashing and i couldn't extract the documents i want to read, after a couple of tries i fired up my terminal to investigate another solution.

First thing first, let's guess the file format of the package. I tought it was a bundle of some sort, but it turned out it was a plain data file.

Xanthia:devs willy$ file DevDocumentation.pkg 
DevDocumentation.pkg: data
Xanthia:devs willy$ 

Wow, not even a clue! let's dive deeper.

Xanthia:devs willy$ hexdump -C DevDocumentation.pkg  | head
00000000  78 61 72 21 00 1c 00 01  00 00 00 00 00 00 02 9f  |xar!............|
00000010  00 00 00 00 00 00 0a 6b  00 00 00 01 78 da ec 96  |.......k....x??.|
00000020  4b 6f 9b 40 10 c7 ef f9  14 88 bb cb be 1f 16 26  |Ko.@.???..?Àæ..&|
00000030  6a 0f 55 7b ab 94 f4 d2  db 3e 66 6d 14 30 16 e0  |j.U{?.???>fm.0.?|
00000040  d4 c9 a7 ef 82 ed 3c 1d  27 4a 9a 2a 87 9e 98 99  |?…ß?.?<.'J.*....|
00000050  fd 33 fb 5f f8 69 20 3f  dd d4 55 72 09 6d 57 36  |?3?_?i ???Ur.mW6|
00000060  cb 59 8a 3f a1 34 81 a5  6b 7c b9 9c cf d2 9f e7  |?Y.??4.?k|?.??.?|
00000070  5f 27 2a 3d 2d 4e f2 8d  69 8b 93 24 ef 1b 17 2f  |_'*=-N?.i..$?../|
00000080  49 ee 16 e0 2e ba 75 9d  74 fd 55 05 b3 b4 5b 18  |I?.?.?u.t?U.??[.|
00000090  9c 0e 2b 49 de 84 d0 41  5f a0 3c db 45 63 b5 2b  |..+I?.?A_?>?Ec?+|
Xanthia:devs willy$ 

Now, not that i really read that kind of hex, but the first 3 chars are "xar", which i remember it should be a new archive format, maybe we have a command to mangle with it?!

Xanthia:devs willy$ xar | head
Usage: xar -[ctx][v] -f  ...
	-c               Creates an archive
	-x               Extracts an archive
	-t               Lists an archive
[...]

Yay! Sounds like "Bingo" to me!

Xanthia:devs willy$ xar -t -f DevDocumentation.pkg 
Bom
PackageInfo
Payload
Scripts
Xanthia:devs willy$ 

Here is the file archive content. How did i know how to use that xar thingie if a minute ago i didn't even know of its existance on my system?! RTFM!

On to extraction.

Xanthia:devs willy$ xar -xf DevDocumentation.pkg 
Xanthia:devs willy$ 

Now that "Payload" is like flashing light wanting attention.

Xanthia:devs willy$ file Payload 
Payload: gzip compressed data, from Unix 
Xanthia:devs willy$ 

Ahh... good old toys...

Xanthia:devs willy$ mv Payload Payload.gz
Xanthia:devs willy$ gunzip Payload.gz
Xanthia:devs willy$ file Payload
Payload: ASCII cpio archive (pre-SVR4 or odc)
Xanthia:devs willy$

Ahh... even more good old toys...

Xanthia:devs willy$ cat Payload | cpio -i
Xanthia:devs willy$ 

Wow, here we go!

We've extracted all the files from the package without installing it, and using only tools already available in every installation of OS X!!

Quick recap: Package files are a XAR file that bundles control files and a Payload, which is a .cpio.gzip file

Tags for this post: Apple, Leopard, Sysadmin, Snow Leopard

And finally...

9 june, only one comment, mind to share your impressions?

Tags for this post: Personal, Apple

The Virgin Mary And The Speed Of Light

27 may, only one comment, mind to share your impressions?

Just a cool excerpt of a chat log with me and a friend of mine... =)

N.P.:
in 1950 they estabilished that the Virgin Mary ascended in body and soul to heaven. soul aside, assuming restricted relativity, where the maximum speed of a body is the speed of light, the Virgin Mary should be now within a ~1950 light years radius...

Biappi:
she didn't get burned during the atmosphere exit?

N.P.:
i don't know... she was a virgin before, during and after the birth of Christ, she can even exit atmosphere at the speed of light

Tags for this post: bla-bla

Runtime Dynamism With Objective-C

20 may, no comments, mind to share your impressions?

Ok, this blog is rarely updated, do i have to apologize every time? No, i don't. :P

With this new iPhone/iPod SDK some friends of mine began writing in Objective-C after ages of Java or C++. Yay for them!

I wanted to show 'em a lil bit of dynamism the objc runtime offers to us. Today, my fellow readers (do i have even one?), we'll try to instantiate an object of a class unknown at compile time.

So, let's start with a basic objc class (no cocoa there)

@interface UsefulClass : NSObject
{
}

-(void)doSomething;

@end;

@implementation UsefulClass

-(void)doSomething;
{
    NSLog(@"Hello, World!");
}

@end;

Indeed this class is really useful.

Let's instantiate it, shall we?

UsefulClass * uno = [[UsefulClass alloc] init];
[uno doSomething];

Nihil sub sole novum, that's just Obj-C 1-0-1, but what if we want to instantiate another object the same class of "uno"?

We can track "uno"'s type just by declaring a class variable, then just asking "uno" itself!

Class unknownClassToInstantiate = [uno class];
id trallalla = [[unknownClassToInstantiate alloc] init];

Yep, it's that simple!

We find out the class with the class message provided by all NSObject-compliant object, which appens to be all objects in a Cocoa environment, then we treat the class variable just like a "real" class name!

It's a matter of alloc/initing the new object!

Now just do that in C++ ;).

Tags for this post: Coding

WWDC: Here I Come!

18 may, no comments, mind to share your impressions?

I've been awarded a WWDC 2008 Student Schoolarship!!

WWDC Badge

See ya in SF!

Tags for this post: Personal, Apple

Look ma, i'm on the news!

4 april, only one comment, mind to share your impressions?

"Pisa, 36 ore in diretta per iPhone" - Punto Informatico.

I feel so important now. =)

Tags for this post: Personal, Coding, Apple, iPhone

All posts are licensed under the Creative Commons Attribution-Noncommercial-Share Alike 2.5 Italy License.
And, because i'm a nerd, i'll proudly tell you that this is a Django Joint!