Updating MacOS: Cannot open file (-3001)

November 20th, 2008

Thought I’d leave a note here for other that may encounter the same issue while trying to upgrade lately. I only got it on my Mac Pro but not on my Mac Mini nor Air.

A networking error has occurred: Cannot open file (-3001). Make sure you can connect to the the internet, then try again.
The terminal came to my rescue. Here is the command:
$ sudo softwareupdate -ia
This will prompt you for your root password and then start downloading the packages. Hope it helps a few until they fix this shitty bug.

Apple: overpriced RAMs, idiot geniuses

October 19th, 2008

I passed by the Apple Store downtown yesterday, hoping to pick up 4GBs of RAMs for my Mac Pro. I guess it works the same in all their stores, I first had to chat with a ‘janitor’ so she can pair me with a ‘genius’.

Why?

The first ‘genius’ assisting me, understood everything I needed but screwed up on 2 occasions: * Confirmed to me that 4GBs would cost $CA 399.99 * Transfered me to a different ‘genius’ when I said I was ready to buy

The second ‘idiot’, didn’t understand nothing. Given the fact that I already had to be transfered and wait for a second time, one can imagine I wasn’t really happy. First, she thought I was talking about the G5 and suggested I wait while she goes and checks if they have some RAMs in stock (even if those were the ones I needed, you don’t keep a digital inventory?!). I take the time explaining to her that it’s not a G5 but a Mac Pro. She then asks me to wait while she helps one of her colleagues with another customer. A couple minutes later she comes back.

Genius: Sir, you are aware that you will have to remove the current RAM you have

Me: No! Why exactly?

Genius: Because you can only have 2 paired sticks at once

Me: Are you serious? I am talking about a Mac Pro - are you really sure of what you are saying?

Genius: Positive sir.

Me: Ok, go on to your site and let me see how the Mac Pro is advertised - 32GBs of RAMs, is that only by using 2 x 16GBs sticks? I doubt it!

Genius: No sir. The Macbook Pro can only take 2 sticks.

Me: Did you just say Macbook Pro? I’ve been talking about the Mac Pro - wake up please!

It doesn’t stop there

She then goes to the back and 10 minutes later, comes back with a carton of RAMs. The curious guy I am, I start playing with the box while she is preparing the bill and notice 2 things: * The box contains 2 x 1GB RAMs, I asked for 2 x 2GB. * 2GBs RAMs are selling for $CA 499, what happened to the $CA 399.95 for 4GBs the other ‘genius’ confirmed?

That’s when I was really fed up to try understanding. I stepped out of the store, logged to eBay while walking to the car and ordered my 4GBs for Mac Pro for less than half the price Apple wants for 2GBs!

The downside

I have to wait until next week to get them…

VAR or VARCHAR, which to choose?

October 4th, 2008

While I was optimizing the database for the application I am currently developing, I thoroughly check the differences between these two types, VAR and VARCHAR, so might as well share my notes here. Keep in mind that these are for MySQL 5.0.3 and later, things were different in certain cases before.

CHAR

  • string, length from 0 to 255
  • required storage depends on the set length
  • values are right-padded with spaces to the specified length when stored
  • trailing spaces are removed when values are retrieved
  • values that exceeds the specified length are truncated, warning is generated (strict SQL mode disabled, otherwise error and not stored)

VARCHAR

  • string, length from 0 to 65,535 (but subject to maximum row size which is shared among all columns)
  • required storage depends on the stored value
  • values are not padded when stored
  • trailing spaces are retained when values are stored or retrieved
  • values that exceeds the specified length are truncated, warning is generated (strict SQL mode disabled, otherwise error and not stored)

Finally, a couple examples to illustrate it all:

mysql > CREATE DATABASE sandbox;
mysql > USE sandbox;
mysql > CREATE TABLE vc (`c` char(3), `v` char(3));
mysql > INSERT INTO vc VALUES ('', ''), ('  ', '  '), ('a', 'a'), ('a ', 'a '), ('abc', 'abc');
mysql > SELECT CONCAT('(', c, ')'), CONCAT('(', v, ')');

That last query will return:

+---------------------+---------------------+
| CONCAT('(', c, ')') | CONCAT('(', v, ')') |
+---------------------+---------------------+
| ()                  | ()                  |
| ()                  | (  )                |
| (a)                 | (a)                 |
| (a)                 | (a )                |
| (abc)               | (abc)               |   
+---------------------+---------------------+

Notice how for CHAR the trailing space is removed. Another interesting thing to note, sorting and comparing CHAR and VARCHAR columns:

mysql > SELECT c = 'a ', v = 'a ' FROM vc;
+---------------------+
| c = 'a ' | v = 'a ' |
+---------------------+
|        0 |        0 |
|        0 |        0 |
|        1 |        1 |
|        1 |        1 |
|        0 |        0 |
+---------------------+

As you can see, it compares values without regard to any trailing spaces.

There, that should resume it all and hopefully help next time there is a field type to set. Did I forget to mention anything? Let me know in the comments.

Beware of the underscore

September 25th, 2008

Have you ever tried using underscores (_) in your controllers variables that you are passing to the view using a combination of Controller::set() and compact()? Well, if you did, you must have realized that they never make it there, right? I haven’t submitted it as a bug yet but here it is:

class SandboxController extends AppController {
    var $uses = null;
    var $layout = 'sandbox';
    function beforeRender(){}
    function index()
    {
        $foo = 'foo';
        $bar = 'bar';
        $foo_bar = 'foobar';
        $this->set(compact('foo', 'bar', 'foo_bar'));
        $john = 'john';
        $doe = 'doe';
        $john_doe = 'john_doe';
        $this->set(compact('john', 'doe'));
        $this->set('john_doe', $john_doe);
    }
}

Now, in your view:

echo $foo . "<br />";
echo $bar ."<br />";
echo $foo_bar ."<br />";
echo "<br /><br />";
echo $john ."<br />";
echo $doe ."<br />";
echo $john_doe ."<br />";

Finally, the returned output:

underscore-bug

Anyone knows if that’s how it’s supposed to act?

Update: there is a way to actually get those variables intact. Thanks to Taylor for pointing it out.

$this->set(compact($foo, $bar, $foo_bar), false);

My current development environment - suggestions?

September 25th, 2008

While I was away, I wasn’t 100% on break… Among the work related stuff I’ve done was revamping my whole dev environment, hardware as well as software.

For a little over a decade now, I have been a Windows user. In the early days, it was because Mac was just too expensive for what my parents could afford for my toys; but since all the Mac-frenzy started, it was more out of fear of loosing some precious time adapting to a new OS (and all what comes with it) than anything else really. I finally decided to give it a try early this year with a Mac mini to start with but that didn’t impress me much at first, mainly because I was never really giving it a real chance to. Only a month or two later, when I got the MacBook Air as a gift from my partner, that I really started enjoying and appreciating the new OS.

I went ahead and purchased the Mac OS X, installed that on the mini, hoping that it will push me into using that little machine some more until I identified the real reason behind my constant bouncing back to Windows: multiple displays. I know you have ’spaces’ in Mac but I still prefer the physical black separation that I get from working with 2 screens (back then), the same reason why I’d rather have 2 x 21″ screens instead of one big display. To my big deception, the mini was not fit for the multiple displays setting because of it’s low-end graphic card - same for the Air.

Around the same time, I was revamping my desk, making it more ergonomic and much simpler. A solid wood board with a metallic bar going horizontally across to support the extra weight, 2 metallic frames for the legs, a keyboard/mouse tray (#02-ORB439BK) w/ ball bearing arm (#02-ARMLKS) and a multi-display desk mount (#30-500-B16-04). The multiple displays were used back then as follow: one on the mini, 2 for the PC and one switching between the FreeBSD box and the docked laptop. Given the fact that I could run all these OS from a central machine, I decided it was time to invest in a real beast, the Mac Pro, for which I had to add an extra VGA card, a wireless ethernet card (- )can you believe this machine comes with no wireless included?) and some RAM.

dev-env-1

Once all that was plugged, the only PC left around was a Toshiba laptop. The temptation to bounce back to Windows was slowly dying and the current setup was only contributing to that.

Now, a couple months later and after having toyed with different tools, here are the ones that I felt worked well for me:

And finally, I keep all files (local sandbox, remote projects, etc.) in SVN repositories for easy access to my files from anywhere. That pretty much covers it all. Since I am new to Mac, maybe there are stuff I’m missing out on, if so, please share. Also, what’s your approach on having your development environment follow you (files, tools, etc.)?

Summer’s over - and so is my break!

September 23rd, 2008

Hi everyone,

I know my posts have been few and far between over the last several months, that’s because I never really felt like getting back to work since I started my break in mid-December ‘07. Who would like to get back to work, right? I have to admit, it felt GOOD! But summer is over now, fall officially started yesterday and for me that means only one thing: it’s time to start getting ready for hibernation mode!

Why hibernation mode? Because, for one, I don’t do any winter sport (and I don’t see myself starting one at this age with a semi-handicapped elbow), I rarely have the need to get out to do things (there’s always someone for every task) and, to be honest, who likes to stick his nose out by -30 celsius? Exactly, not many, when given the option.

And basically, now that I’m seriously back, you shall see a lot more coming from me on this blog in the days, weeks and months to come. Maybe finally doing the move to it’s own CakePHP-based CMS and domain?

Hack into any MacOS X

May 19th, 2008

Early this week, I finally went and purchased Leopard to upgrade my Mac Mini and start running the same MacOS version on all computers I use. Everything was going good until the automated system reboot. Somehow, on the login prompt, my root access wasn’t being authorized anymore.

simple search quickly revealed I wasn’t the only one that ran into this kind of issue, every Mac user that had a password of 8 characters and more faced the same problem. But now what’s the solution when your root password is a long one?

You will be relieved to hear that Apple’s software engineers already thought of that. Actually, I don’t know how much thought was put into it, but there is a solution available. The only problem is that this same solution can be used by anyone on a computer running MacOS X (haven’t tried older versions) to gain root access.

I’ll let you judge for yourselves.

Back from a long break…

May 16th, 2008

Wow - my last post was on December 6th, over 5 months ago! Having to write after all this time makes me feel like it was the first post ever… Where to start? Nowhere.

I can see that things have been moving pretty quickly in the CakePHP world: CakePHP 1.2 Beta, 1st CakeFest (damn, I missed that!) and last but not least, the Cookbook.

My highlights of the past 5 months:

  • Moved back to Montreal
  • Migrated from WinXP to Vista (very short) to Mac OS X
  • Massive workstation upgrade
  • Took a loooong break from work
  • Hired new staff 
Some of the big changes to expect on the blog:
  • Moving soon to its own domain
  • Mike will start blogging in the coming weeks (my latest recruit on the development team)
  • Getting a facelift sooner than later
I’ll leave it at that for the moment… After all, it’s just to say am back ;)

HtmlSource - a new DBO driver for CakePHP

December 6th, 2007

Ok, ok - I’ve been slacking on this blog again, but I will keep that for another post where I will announce some major changes I have been thinking of lately. For today, I’d like to introduce the new DBO Source Driver: HtmlSource - which is completely functional but still lacking some of the features I have planned for it.

So what’s an HTML DBO driver you ask?

Simply put, it’s a way to treat any HTML page like a database and be able to retrieve (scrape) certain parts using an SQL-like command:

SELECT href, title FROM a WHERE class="submit"

Read the rest of this entry »

PHP releases 5.2.5 to fix multiple vulnerabilities

November 15th, 2007

For the ones of you who have not opted to receive the PHP announcements from the php.net site, here’s an important one you shouldn’t miss if you are using the 5.2.x branch.

From the PHP team:

over 60 bug fixes, several of which are security related
Some of the vulnerabilities are:
  1. Various errors exist in the “htmlentities” and “htmlspecialchars” functions where partial multibyte sequences are not accepted.
  2. Various boundary errors exist in the “fnmatch()”, “setlocale()”, and “glob()” functions and can be exploited to cause buffer overflows.
  3. An error in the processing of “.htaccess” files can be exploited to bypass the “disablefunctions” directive by modifying the “mail.forceextraparameters” php.ini directive via an “.htaccess” file.
  4. An error in the handling of variables can be exploited to overwrite values set in httpd.conf via the “iniset()” function.
More details can be found in the official announcement here.