fluffigt.com *poof* said fluff….

23Aug/080

Private methods in PHP programming – response

Felix over at Debuggable wrote an interesting article about private methods. He thinks it's not a very good thing to use, but, kudos to him, doesn't rule out the possibility. He argues that he doesn't have any formal education in programming and development, but I don't think that matters much at all since he seems to have quite a bit of programming experience.

But what I think is that, of course, you alwas can write private-method-free code, but sometimes it's not very good. When you need to duplicate code time after another, you might begin to see the need for another method (refactoring) or for that matter class. What that method does or returns maybe, just maybe, isn't that good for the rest of the world (read application) to access directly rather than through your other, more high level methods.

CakePHP itself is has lots of private methods. Could we do without them all? Of course we could. Would it make the code easier to read? Maybe. Would it make the code easier to maintain? I think not.

With that said, you always need to make an active decission whether you choose to make a method public, private or protected. Chances are, if you only write public because you are used to it, you might be making a mistake that could compromise stability or security of your application if another developer makes use of that method...

22Aug/080

Power consumption on office switches

Russel Coker wrote about switches and cables, and thinks putting a "dumb switch" on every desk is a good solution for office networking. He's got a couple of valid points, for example that it's possible to use less cables from the patch room, no (or less) dependency on network gurus and so on.

What he doesn't talk about is that

  • Power consumption goes up. Each office switch typically uses between 5W and 10W depending on how good the AC/DC-adaptor is. (example of WRT54 power consumption)
  • You get many more SPOF. Okay, most switches actually works quite good, but office support will have to answer a great many calls of "Internet is down" etc.
  • Configuration of a "real" switch isn't that complicated, draws less power and usually gives _many_ more possibilities than the dumb table-top switch (ie VLAN, bridging, QoS, ...)
17Aug/080

Sony Giga Juke NAS-SC55PKE

IDG.se skriver om Sony Giga Juke NAS-SC55PKE som iofs verkar kompetent och småtrevlig, men börjar man jämföra med Sonos paket Sonos Bundle 150 är det inte lika imponerande längre. För ungefär samma peng får man i och för sig högtalare och inbyggd CD-spelare och en hel 80GB-disk, men den verkar inte ha samma möjlighet med Internetradio, endast möjlighet till 5 zoner (jmf 32), tidsförkjutning i "Party mode" och så vidare, så känns det som att om man ända ska lägga ut tiotusentals kronor på att sprida ljudet man har i hemmet, så kan man väl göra det bra från början? Jag är riktigt imponerad av Sonos, men tyvärr blir det ingen sån här lösning för mig förrän jag flyttat från 1:an till något större...

9Aug/080

Upgraded Popcorn Hour

A new, upgraded, Pocorn Hour seems to be released. It's product name is A-110 and I really hope it will be for sale in Sweden soon... New features include HDMI 1.3a, SATA and USB slave functionality.

Links:

18Jul/080

xen 3.02 on Debian Etch / AMD64

A quick walk-through of installation of Xen 3.02 on Debian Etch (AMD64):

KERNELS="linux-2.6-xen0 linux-2.6-xenU" make -j7 world
make install
make linux-2.6-xen0-config CONFIGMODE=menuconfig
make -j7 linux-2.6-xen0-build
make linux-2.6-xen0-install
make linux-2.6-xenU-config CONFIGMODE=menuconfig
make -j7 linux-2.6-xenU-build
make linux-2.6-xenU-install

vim /boot/grub/menu.lst

title Xen 3.0.2 / Debian GNU/Linux, kernel 2.6.16
root (hd0,0)
kernel /xen.gz dom0_mem=131072
module /vmlinuz-2.6-xen0 root=/dev/sda2 ro console=tty0
savedefault

Install xen-tools, xen-shell etc

update-rc.d xend defaults 20 21
update-rc.d xendomains defaults 21 20

7Jul/080

Accountability and signatures

Here's a really great idea from Bob Planket over at The Lone Sysadmin.

Tagged as: No Comments
6Jul/080

Många svenskar är onyktra på sjön

Enligt en artikel i DNs nätupplaga är det många som är onyktra på sjön, vilket säkerligen stämmer och är ett problem i många fall. Det jag däremot reagerar över är misshandeln av statistik:

Var femte av de drygt 2 000 tillfrågade i åldrarna 19-70 har varit ute med en fritidsbåt med fem starköl i kroppen, och 35 procent har åkt båt efter att ha druckit motsvarande två starköl. Anders Wernesten, informationsansvarig på SLS, menar att siffrorna tyder på att många även kör båt onyktra.

Det första jag frågade mig, speciellt med att 35% "har åkt båt efter att ha druckit ... två starköl" är: hur många har inte åkt finlandsfärja och tagit ett par öl? Det andra jag frågade mig var: hur många har druckit så mycket och därefter satt sig i en bil, buss eller tunnelbana?

Jag har inte kunnat hitta någonting om den här rapporten, varken som länk från DN eller på SLS hemsida, så jag och övriga läsare kan egentligen inte säga oss veta mycket mer om verkligheten. Däremot vet vi att kustbevakningen vill ha mer medialt stöd för att få göra alkokontroller till sjöss 🙂

För övrigt anser även jag att en promille är väldigt mycket att ha i kroppen om man ska köra en båt, och att det nog borde specificeras hårdare hur det ska fungera när man blir "haffad" så att man faktiskt får böter, eller blir av med rätten att framföra båtar...

4Apr/080

No 404 page when using a static front page

I was setting up a wordpress blog (latest version, 2.5) a couple of days ago, and added the great plugin Google XML Sitemaps. I wanted a static frontpage with a couple of blog posts below it, so I modified the Kubrick theme a bit (added another template to use for that page, no biggie).

When taking a look at Google Sitemaps (somewhere under Google Webmaster Tools) I found that WordPress didn't respond to non-existing pages with a 404 not found, but all my pages after each other, rather like the posts on a dynamic front page.

Again I thought - no biggie! I modified the 404.php template to begin with the following:

<?php
ob_start();
header("HTTP/1.1 404 Not Found");
header("Status: 404 Not Found");
...

Still, no luck. Then I saw that WordPress didn't even read the 404.php page! I tried turning off the static front page and voilà, 404 works okay again.

I've searched a bit for this in the WordPress forums, but I'll report a bug ticket for them. Hopefully it will work in the next release 🙂

Newsflash:

It only works this way if you haven't chosen a "Posts page". Maybe it's just an undocumented feature?

2Apr/080

WordPress upgrade

After upgrading to the latest greatest version of WordPress I noticed I can't create links in new posts anymore.

That wasn't what I was about to write, but it became very apparent when I tried to link to the WordPress blog post about the new version. What I was about to write about was that all my plugins seems to work really well even though they were written before WP 2.5 was even thought about. And that I really like the new "admin interface" with dashboard and more.

Now if I could just get a couple of more hours per day so I could finish off some of my projects 😉

Tagged as: No Comments
1Apr/084

Symfony development with XAMPP on Windows

This is how I set up my windows laptop for development with Apache/MySQL/PHP/Symfony (XAMPP with Symfony).

  1. Download XAMPP Installer package.
  2. Install XAMPP - this is really just a case of next -> next -> okay.
  3. Since I'm not only using my laptop for development I chose not to start any services except for XAMPP when windows starts.
  4. Start (from XAMPP Control Panel) Apache and MySQL (and whatever other services you need).
  5. Add PHP to your PATH.
    1. Right-click "This Computer", choose properties.
    2. Advanced tab -> Systam variables (not sure, my system is in Swedish 😉 )
    3. Add C:\xampp\php;C:\xampp\mysql\bin (if installed in default location) to the PATH variable.
  6. Upgrade Pear - pear upgrade pear
  7. Find Symfony - pear channel-discover pear.symfony-project.com
  8. Install Symfony - pear install symfony/symfony
  9. Done! Start playing around...