Manual duplex printing on a laser printer

My laser printer, a Samsung CLX-3175, does not have any tool for automatic duplex printing. Achieving such result manually is not difficult, but may take some trial and error in order to get the settings right. That’s exactly what I’ve done, and I’m writing this post as a note to myself. Should it be useful to anybody else, however, by all means let me know with a comment.

Keep in mind that this is for my own printer, and that I use OS X 10.6 “Snow Leopard.” Results may vary with different printers and/or operating systems, so make your own tests. If your printer outputs pages “face down,” this will probably work as it is. Most ink-jet printers on the other hand output prints “face up,” so some adjustments will be necessary.

In any case the steps for my own printer are very, very easy (once you’ve figured them out correctly):

  1. Print all odd pages in normal order
  2. If the total number of pages is an odd number, take the last sheet and put it away for the time being
  3. Take the (remaining) sheets and put them back into the tray after rotating them 180°. Do not flip them in any way!
  4. Print all even pages in reverse order
  5. If you put the last sheet away in step 2, put it back at the end of the stack
  6. There is no step 6

Enjoy. 🙂

TV shows I’ll be watching

In case anybody cares, here is what I will be watching:

  • Weeds (season 6), Showtime, Mondays — in progress
  • Cougar Town (season 2), ABC, Wednesdays — starting Sept. 22nd
  • The Big Bang Theory (season 4), CBS, Thursdays — starting Sept. 23rd
  • 30 Rock (season 5), NBC, Thursdays — starting Sept. 23rd

Of course, if you — like me — don’t live in the US, there are ways to watch them almost live. You could start looking at the sidebar of this blog, for instance.

Why am I saying this? Well, I may write about the shows here as I have done in the past, so be warned.

Incidentally, you may notice that they’re all sitcoms, aside from Weeds which is somewhat difficult to classify, but definitely has quite some humor. That’s because the days are getting shorter, the weather is getting worse and S.A.D. is lurking in ambush behind the corner. By the way, do those Philips LivingColors thingies help at all?

Prettifying URLs with fake subdirectories using mod_rewrite

Lately, I have been trying to define a common basis for most of my web projects, since I often end up reinventing the wheel every time. I have tried a few PHP frameworks, but none of them tickled my fancy, but I have complicated tastes. I am known for reimplementing something from scratch rather than wasting time adapting other people’s code to my needs, and it’s often much faster too.

Therefore I have been working on JBFW, my very own PHP/Javascript framework. One of the key components of it is pretty URLS and a centralized index.php to handle most of the things.

If you access, the server will transparently route that to At that point, index.php runs the news module if it’s present, and then loads the news template (possibly showing the result of what was done in the module, if it was called at all.) I find that it’s a very slick and modular way of handling things, as static pages only need new templates and boom, they are live, with the rest of the framework readily accessible.

The mod_rewrite configuration for such a behavior is as follows:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?pagename=$1&%{QUERY_STRING}

This means: if the requested filename is not a directory and is not a file, route the request as described (knowing something about regular expressions, or being proficient in creative swearing — which goes hand in hand with regexp — comes in very handy at this point.)

I used a similar, but coarser, approach on my own main website, There, I even used fake subdirectories, so that will have it show the photography-book-glimpses template. Neat, but doesn’t work with real subdirectories. It’s not a big problem on that site, but when you need to have a separate administration section, you need real subdirectories. The problem is that, using the approach I described above, into, and while the correct function could be run in PHP by mangling the request as it’s done for the “top level” modules, it could quickly turn into a nightmare.

The solution is to add another set of mod_rewrite rules, as follows:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((.*)/)+(.*)$ /$2/index.php?pagename=$3&%{QUERY_STRING} [L]

Yes, that’s incredibly messy, and I’m pretty sure that there is a better way to do it. However it works, and for now I’m going to concentrate on finishing the website and go back to it later. What this does is: if the request has one or more blocks ending wish a slash (the directory), followed by something else (the file name), it is routed to index.php inside that directory, using the file name as a parameter to pagename, plus the original query string as usual. The [L] at the end tells mod_rewrite: please refrain from doing any other change, this is flaky enough. This ensures that effectively calls

Note that this is another block of RewriteCond and RewriteRule, and goes before the original one. I tried to put them together, since the conditions are the same, but after fifteen minutes of trying all combinations I gave up. I’m sure I was one attempt away from getting it right.

A very clever thing (ok I’m kidding, it’s a side effect I hadn’t fully realized but I’m glad it’s there) is that addresses such as img/logo.png are not rewritten because those files do exist. It would probably make sense to exclude common file extensions, such as image files and javascript, from this kind of mangling; or even better, make it only work when the “file name” part does not have a dot in it. I’ll find a way to do it, at some point.

To finish up, an extra little trick that can come in very handy when you want to make sure that certain files are not downloadable by anybody:

<Files ~ "\.sqlite3$">
Order Allow,Deny
Deny From All

Make sure that there are no spaces on either side of the comma in the first line. I was quite frustrated because I kept getting the infamous error 500, and there it was.

I hope this spares someone from wasting as much time as I did with this kind of thing!

20 tips to run a business without committing suicide

Starting earlier this year, I have been a “professional” IT consultant (libero professionista in Italian.)

In practice I mostly deal with web development and computer repairs. It’s what I’ve been doing for over a decade now, since I was still in school, only now I get to pay my own taxes (yay) and therefore I get angrier when people try to rip me off. So, here’s a collection of tips about running a business I put together based on my experience. Note that I refer to the client as a “he,” but that’s just for simplicity.

  1. Befriend a lawyer. You will need one sooner or later. Most likely sooner.
  2. Assume the client doesn’t have any clue on the details of your job. Listen to his ideas, make a mental note of how you’ll approach the problem in practice, and be ready to explain to him why his “perfect” solution just doesn’t work and needs to be achieved differently.
  3. Use lots of metaphors to explain to the client why you’re doing what you’re doing, and why you’re not doing what he thinks you should be doing. Cars and houses are what people understand the most.
  4. Always require an advance payment to start a job and always require the settlement to deliver it. This protects the client from an unfinished work, and protects you from an unpaid work: if the client doesn’t settle, he loses the advance and doesn’t get the job delivered.
  5. Approved and signed quotes are fine for small jobs, but for anything more complex, a full written contract is best. Be shielded from requests that were never discussed in the first place.
  6. Don’t be afraid of writing long contracts. Rather, make sure you cover everything in clear terms. And use a big font. Contracts in small fonts are scary to most people.
  7. Assume all clients are going to try and rip you off: give little trust to strangers, trust friends even less, and just avoid relatives altogether.
  8. If a client asks for a discount, especially if it’s the first time they come to you, deny it and remind them that discounts are a (rare) privilege, not a right.
  9. Do not give discounts on the first job upon the promise that a client will come back to you, because they most likely won’t. Rather, have him pay full price on the first job and promise a discount on the next one.
  10. If some problem arises during the execution of the job, let the client know immediately, even if it’s something trivial. They will appreciate the openness and it’s a good long-term marketing strategy. By the same token, give the client as many details about the work as he needs, but no more. Too much information yields the opposite effect and confuses him.
  11. Do not plan your financial life around prospective clients. Until a quote or a contract is signed, there is no client.
  12. Realize that most clients do not check e-mail regularly or that they are unable to use it properly. You will be in touch with your clients over the telephone.
  13. Take note of the timeline of a job, ie. how long the client takes to do his part (send you materials, issue the payments, etc.) This will let you profile the client so that you can subsequently offer discounts or raise the price accordingly.
  14. Set a base price for the job, and always give a higher quote. Even if the client accepts it as it is, it leaves you room to reduce it and make a good impression on him. Again, this is good long-term marketing strategy. Moreover, learning the fine art of haggling allows you to anticipate your client’s moves and counter them.
  15. If your area has geographical stereotypes about work ethics, be prepared to see them reversed.
  16. Round prices so that they are more client-friendly when including tax, but always think before-tax for your own planning.
  17. Use legalese only when things get rough and you are getting ready to call your lawyer into the game.
  18. If possible, send printed invoices by mail after signing them. This is often pointless, but gives you the chance to add a bunch of business cards that your client can give around if they’re satisfied.
  19. Use a secondary phone number for work and give it around whenever you have the chance.  The more people have it, the more potential clients have it. And you can always turn it off if you need a break.
  20. Accept the fact that dealing with clients is like going to war. It’s bloody, messy, time-consuming, frustrating, psychologically impairing and even when you win, you wonder whether it wouldn’t have been a better idea to buy some land and grow carrots and potatoes instead. And in most cases, it would have been a great idea indeed.

Cougar Town, a lighthearted sitcom worth watching

Cougar Town is an ABC sitcom focusing on the life of Jules Cobbs, a recently-divorced 41-year-old woman (played by Courteney Cox) who struggles to find a new partner and ultimately her place in the world, as most men her age are either married or going after younger girls.

The name of show is obviously a reference to the slang word “cougar,” which refers to an older woman who pursues younger men (see Wikipedia), and to the football team mascot of the local high school. However, do not expect to see a woman chase young man after young man, because — despite what the first few episodes might suggest — that’s not how the story unfolds at all. Indeed, the first season explores the life of a group of 40-something friends (both married and divorced), and that of Jules’ son.

The writers chose a lighthearted approach to all the topics touched by the show, and that’s probably why it works. There isn’t much room for deep, philosophical conversations between any characters, and their “life-changing revelations” are fast-paced and often quite dull. One might wonder whether the characters themselves are that superficial, or if they deliberately choose not to seek important changes in their lives, settling for the path of least effort.

Still, as I said, the whole thing works. Keep in mind that this is not a show you’re going to watch if you’re looking for intricate storylines or subtle details that only come up when you play the episode again. You still find yourself looking forward to what’s happening next, no doubt, but it’s more out of curiosity than anything else. In other words, you will likely not “root” for any characters; except maybe Andy, as the guy is so clumsy and resigned that you can’t help but wish that he finally gets his way sooner or later. In any case the acting is not bad at all, and the two other female characters’ approach to life, Ellie (Christa Miller) and Laurie (Busy Phillips) do change quite a lot over the course of the show.

An interesting thing I noticed is that, while sex is inevitably a common topic and you will get clear visual clues that a couple just made love (that is, cuddling in bed under the sheets), there isn’t any nudity at all. However, even with the lighthearted approach, I suspect that a kid — and maybe even a young teenager — would fail to grasp many of the implications of divorce, age disparity and so on.

This leads me to the only complaint I have about the series: the liberal use and promotion of alcohol, specifically wine, by virtually all the characters except Travis, the son. One episode actually pivots about Jules’ attempt to stop drinking, resulting in an unusual intervention by anybody else to urge her to start drinking again. While, as I said, Cougar Town is certainly not targeted at kids or teenagers, I am surprised that such glorification of alcoholic beverages made it through. Let’s not forget that we live in an era in which there have been attempts to rate movies as “R” simply because someone smokes in them.

The episodes are quite short, barely touching 22 minutes each. If you have access to the box set or to the video files, that means that the whole first season will take less than nine hours to go through.

All in all, Cougar Town is a nice show to watch and every episode is packed with comic moments and funny quotes that will not fail to entertain. Here are a few clips to give you an idea:







And if you manage to watch season 1 quickly, you’ll be pleased to know that season 2 premieres on September 22nd.

Dream Theater’s responses to Portnoy’s departure

A few hours after Mike Portnoy left the band, the other members of Dream Theater have started to comment on the issue.

James LaBrie wrote on his website’s forum:

Hi Everyone,

Thought I would give you time to digest the news of Mike’s departure. MIke stated that he was burnt out with the DT world and needed a break. We have to respect where he is at and where this will lead him at this particular point in time. With that being said, we are more than pumped to continue the legacy of DT and jump full on into the next chapter. Rest assured it will be great. You can count on it.

On another positive note. Matt and I are psyched with the reaction and reviews ‘Static Impulse is receiving around the world. We can’t wait until everyone can get their hands on the complete disc. and hear it the way it was intended.

I will be around more often to see how you’re all doing and to fill you with any and all news. Take care and not long now until the 27th or 28th depending on where you live.

Kick it up a notch,


John Petrucci wrote on his website’s forum:

Obviously you’ve all heard the news of Mike’s departure from Dream Theater by now.
I felt it important to open up a line of communication in an effort to kill any rumors and to promote clarity.
I love Mike and really hope he’s happy and successful in whatever he does.
I realize that Mike was always the one to actively stay in touch with our fans, and I just wanted to let you know that I’m going to try to be at least a bit more present on both mine and DT’s websites and to let you all know that I am here.
To me, Dream Theater’s story is one of defying the odds, standing for true integrity in music and creating our own success through perseverance and hard work, so although Mike’s leaving is heartbreaking, I still look forward to an amazing musical journey that continues on with some of the most talented and respected musicians and composers on the planet!

Jordan Rudess opted instead to post a video on YouTube, saying:

Everyone is asking me to comment on my thoughts about Mike Portnoy leaving Dream Theater and this huge change that has happened in all of our lives. I have always been able to express my feelings and do my best “talking” through music, so I decided to voice my statement in this improvisation. Hope you “understand”

Here is the video:


I posted this comment to it (it’s already on page 3 as I’m writing this, but it will fall deeper and deeper as time goes by):

Something must have happened. Jordan was remembering the good times, but the “ticking” at the ending followed by the angry final chord gives me the impression that there was a lot of tension building up and that the departure was not as peaceful as the press releases claim it to be.

Incidentally, I sense a bit of “it’s their fault, they didn’t respect me after all I do for the band” vibe in MP’s post.

DT is not MP. DT included MP, but doesn’t strictly need him. The Spirit carries on.

I couldn’t find any note by John Myung — he doesn’t even seem to have an official website —but I’m pretty sure that nobody is surprised about that. 🙂

Mike Portnoy leaves Dream Theater

Dream Theater has released a short press release on their website:

To all of our loyal fans and friends: It is with profound sadness — regret — we announce that Mike Portnoy, our lifelong drummer and friend, has decided to leave Dream Theater. Mike’s stature in the band has meant the world to all of us professionally, musically, and personally over the years. There is no dispute: Mike has been a major force within this band.

While it is true that Mike is choosing to pursue other ventures and challenges, we can assure you that Dream Theater will continue to move forward with the same intensity — and in the same musical tradition — that you have all helped make so successful, and which is truly gratifying to us.

Fans and friends: File this episode under “Black Clouds and Silver Linings.” As planned, we begin recording our newest album in January 2011, and we’ll follow that with a full-on world tour. “The Spirit Carries On.”

All of us in Dream Theater wholeheartedly wish Mike the best on his musical journey. We have had a long and meaningful career together. It is our true hope that he finds all he is looking for, and that he achieves the happiness he deserves. He will be missed.

Also, Mike himself posted this tweet:

This is a sad, sad day….I’m afraid I have some bad news…. MP/DT Sept 1985 – Sept 2010

And then this note on his Facebook page, which is thankfully accessible to non-Facebook users (otherwise I wouldn’t be able to read it):

I BEG of the fans to please NOT hold A7X responsible for MY decision…they are just as shocked as you guys..I had been contemplating this and desiring a “break” (not split) as long ago as last year…everything else is fully explained in the press release…thank you all for your support and understanding…this is the hardest thing I’ve ever done… : (

This is bad news, but I already knew this would happen soon. See, all Dream Theater’s members have been involved in side projects all along. It’s just the way they are: they are great musicians, and they can’t stand still. James, just to give an example, released several solo albums (“Mullmuzzler” 1 and 2), and participated in True Symphonic Rockestra and in Ayreon‘s “The Human Equation.”

However, Mike lately had not only released an album with Avenged Sevenfold (A7X) and toured with them (John Petrucci did the same with the G3 project, after all), but just by following his tweets you could easily tell that A7X had become “his” band. On September 5th, he tweeted: “Its 3:30am and I am getting tattooed by Grant Cobb on a moving A7X tour bus after losing a bet to Dan The Body…this aint DT!!”

Don’t get me wrong, I’m not judging. It’s just that Dream Theater is, if I am allowed to say so, “purer” than any other progrock band out there. Alright, alright, that’s the hardcore fan in me talking, right. But surely everybody would agree that Dream Theater is more like Marillion on steroids than cousins of Metallica, right? All the other members of Dream Theater have “grown up and calmed down,” in a way, whereas Mike seems to be, well, the wildest of the bunch, even though he recovered from his alcohol and drug addiction.

His path with Alcoholics Anonymous has indeed been put into music by Dream Theater over the course of five albums, since 2002, in what is called the “Twelve-Step Suite”:

  • The Glass Prison, from Six Degrees of Inner Turbulence (I – Reflection; II – Restoration; III – Revelation)
  • This Dying Soul, from Train of Tought (IV – Reflections of Reality; V – Release)
  • The Root of All Evil, from Octavarium (VI – Ready;  VII – Remove)
  • Repentance, from Systematic Chaos (VIII – Regret; IX – Restitution)
  • The Shattered Fortress, from Black Clouds & Silver Linings (X – Restraint; XI – Receive; XII – Responsible)

All these songs’ lyrics carry a dedication to “Bill W. and all of his friends.” Why all the parts’ names begin with the letter R is currently unknown; however, knowing Mike’s passion for nuggets, it’s not a coincidence.

Still, some people in 2002 feared that Dream Theater’s career would end with the completion of the Twelve-Step Suite. These fears were mostly quenched when they signed with RoadRunner Records in 2005, and many think that Octavarium tells the story of their relationship with recording labels.

Still, the question now stands: what will happen to Dream Theater? Mike Portnoy had been producing the band’s albums for a long while. He may still keep doing that, of course. But who is going to replace him? How will the music change? I am one of those who thinks that Images and Words was their best album, followed by Scenes from a Memory. The freshness of the former was probably influenced in part by Kevin J. Moore, and the latter bears a distinct “Rudessness” to it.

I wish Mike the best for his career, but as a long time fan, yeah, I’m speechless. I hope that this will mark a return to origins for Dream Theater: after all, we (they) have gone through three keyboardists and two (actually three) singers. The point is that while we are “used” to changing keyboardists (no offense to Jordan, I’m glad he’s on board even though, well, Kevin was Kevin — sorry about that), changing drummers is like replacing a load-bearing wall in a building. Everything might crumble. Let’s hope not.

Rock on.

Edit: Mike also posted a detailed note on his website’s forum.

Fix broken IMAP attachments in

I have recently started getting broken images in Often, when someone sent me relatively big pictures (over 1 MB in size), the image ended up being corrupted, with a smaller file size that one would expect. This results in a picture that’s visible up to a certain point, and then rest is usually filled with solid grey by the viewer.

While this could happen because the attached image is indeed broken — that is, if the sender is attaching an image that’s already corrupted on his/her machine —, it’s unlikely that the file gets mangled during the transit. To begin with, the base64 encoding adds lots of CRC (1/3 of the file size, and this alone explains why it’s a very bad idea to send big files through e-mail). In addition to that, no MTA will accept a malformed message: MIME parts must be completed with an extra boundary marker, and the infamous dot on its own line has to be there to commit the DATA part. Using a webmail system makes it even more difficult to corrupt a file in transit, because there is the extra uploading step that ensures that the attachment reaches the server before the message is constructed and finally sent.

If none of this makes sense and you want to know more, please refer to RFC 2821, but the point is that it’s virtually impossible for several people to send corrupted images. It’s way more likely that the problem lies within the recipient’s client.

With OS X’s, these problems happen when there is some communication failure during the download of the message. Essentially, if the download gets interrupted for any reason, may be unable to notice and will be perfectly happy with the broken file. There are two ways to fix this:

  • The hard way: go to ~/Library/Mail, and for each INBOX you may have, delete anything inside the Attachment folder
  • The easy way: select your Inbox folder within and simply run Mailbox → Rebuild

That should take care of the problem. Note that the Rebuild procedure will redownload every message from the server again with all the attachments, essentially resynchronizeing the local cache with whatever is on the server, fixing any discrepancies. It may take some time, but you can keep an eye on the progress by opening the Activity window (Window → Activity, or ⌘0.)

Chords for “Soft Kitty,” from The Big Bang Theory

One of the funniest “inside jokes” of The Big Bang Theory is the song that Sheldon’s mom used to sing to him when he was sick. It’s featured in three episodes, as you can see here:


The song is, like most lullabies, very simple. I came up with the chords earlier today, while jamming with my ukulele. Here they are, for all my musically-inclined nerdy readers. Corrections are welcome.

[G] Soft kitty, [C] warm kitty,
[G] little ball of [D] fur;
[G] happy kitty, [C] sleepy kitty,
[G] purr, [D] purr, [G] purr.

Interesting trivia: they are almost the same chords as The Lion Sleeps Tonight, except for a minor difference in the last verse that shouldn’t prevent the most creative among you to fit one into the other.

Should you prefer so, you could play it as C F C G / C F C G C or by whichever transposition makes you happy.