boydjd's blog

boydjd's picture

HAPPY CAPSLOCK DAY

CLASS DUMBCLASS
{
  PUBLIC STATIC FUNCTION CAPS(&$S)
  {
    $S = STRTOUPPER($S);
  }
}

$CRAP = "hello";
DUMBCLASS::CAPS($CRAP);
ECHO $CRAP;

boydjd's picture

How-to: Replace Keys of an Array in PHP

I had a need tonight to replace the keys in an array in PHP. I couldn't find a good solution on any mailing lists or other sites, so I thought I'd share the class that I came up with, and it's test.

First up, the test:

<?php
require_once 'PHPUnit/Framework.php';
require_once 'ArrayHelper.class.php';

class ArrayHelperTest extends PHPUnit_Framework_TestCase
{
  public function testRenameKeys()
  {
    $keys   = array('newkey1',
                    'newkey2',
                    'newkey3');
                   
    $array  = array('oldkey1' => 'value1',
                    'oldkey2' => 'value2',
                    'oldkey3' => 'value3');
                   
    ArrayHelper::renameKeys($array,$keys);
   
    $this->assertArrayHasKey($keys[0],$array);
    $this->assertArrayHasKey($keys[1],$array);
    $this->assertArrayHasKey($keys[2],$array);
    $this->assertEquals(3,count($array));
  }
}

Next, the class itself, after the jump.

boydjd's picture

Frozen Food Review: Michelina's Budget Gourmet Classics Pasta & Chicken

Today I made the decision to stop ordering take-out, and stock up on frozen/instant food to save some money instead of dropping it all on take-out food that ends up all tasting the same anyways. In this light, I've decided that I'll also review the frozen foods that I choose to consume so that other programmer types who have no time to deal with the hassle of cooking (yes, I know how to cook) can make educated decisions on what frozen foods to eat/avoid.

The first meal in this review is a Pasta and Chicken dish from Michelina's, from the "Budget Gourmet Classics" series.

boydjd's picture

Algebra's Awesome!

Yes, Steve. Yes it is.

boydjd's picture

Text of Mantasano's Article on Detais of Kaminsky's DNS Attack

Unless you've been living under a rock today, I'm sure you've been hearing about the Matasano blog leak of the details of Kaminsky's DNS attack. It was ripped off the site, and most other sites who've had it posted up have had it ripped down as well. I'm posting the story here in it's entirety, simply because it's interesting, and I think everyone has a right to know. Regardless, all of the vendors have released patches for this vuln already. If the ISPs haven't patched yet, it's on them, not Kaminsky, Matasano, ecopeland, or me for reposting it.

Enjoy.

boydjd's picture

How Software Companies Die by Orson Scott Card

The environment that nutures creative programmers kills management
and marketing types - and vice versa. Programming is the Great Game.
It consumes you, body and soul. When you're caught up in it, nothing
else matters. When you emerge into daylight, you might well discover
that you're a hundred pounds overweight, your underwear is older than
the average first grader, and judging from the number of pizza boxes
lying around, it must be spring already. But you don't care, because
your program runs, and the code is fast and clever and tight. You won.
You're aware that some people think you're a nerd. So what? They're
not players. They've never jousted with Windows or gone hand to hand
with DOS. To them C++ is a decent grade, almost a B - not a language.
They barely exist. Like soldiers or artists, you don't care about the
opinions of civilians. You're building something intricate and fine.
They'll never understand it.

boydjd's picture

New Toy --- ASUS eeePC 4G Galaxy Black

It's been awhile since my last post, been busy working 100+ hour weeks at a startup.

Anyways, I picked up an ASUS eeePC 4G in Galaxy Black last week, along with 2GB of ram to juice it up. The default linux install didn't really impress me, so I've wiped it out and install eeexubuntu on it, which runs pretty well. So far I'm impressed by it, I did hack the keymaps so that shift was in the proper place on the keyboard. Next things I'm looking at doing are hardwiring two 32GB USB flash drives inside of it, and setting them up in software RAID 0, to expand storage from 4GB to 68GB or so. Might go completely crazy and drop 3 of them in and do RAID 5 ;) I'm also considering wiring up my ATT USBConnect card, however, it appears linux support is lacking, so if I go that route I'll have to see if I can load OSX onto it first. I'm not really very excited about the prospect of loading Windows onto the eee, but we'll see what happens.

I've also "overclocked" the processor from 633MHz to 900MHz, which is it's native speed. Apparently ASUS felt it was a good idea to downclock, I felt otherwise obviously. This can be done with the eee.ko kernel module via software, which also allows temperature monitoring and manual fan control.

boydjd's picture

Script Kitties

 I love reading my security logs that get e-mailed to my nightly. Apparently script kitties think that they can get into my server by launching 5 million SSH sessions with random usernames and passwords.So do I null-route them, or let the kitties play? Undecided.

boydjd's picture

Top 10 Commands Used

Personal MacBook top 10:

Darwin joshua-boyds-macbook.local 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar  4 21:17:34 PST 2008; root:xnu-1228.4.31~1/RELEASE_I386 i386
joshua-boyds-macbook:~ joshuaboyd$ history | awk '{a[$2]++} END {for(i in a){print a[i] " " i}}' | sort -rn | head
119 ls
87 cd
31 vi
25 ssh
25 ping
19 gprof
19 g++
18 cat
16 pwd
16 more

boydjd's picture

Design Coding fo real

Slice dat design.
Do your layout wit divs.
Please don't use tables, even tho they work fine.

Make it easy for the providers to crawl what you design.

Word.

Gotta make sure dat it renderz correctly

Syndicate content