Latest |Kites |Pictures |Programming |Life
?
[filed under life]vista sucks

OK, this is how utter turd Vista is. I have a folder that is in my Documents. I can't delete it.

I right click -> delete. It asks am I sure. Then asks am I sure (again), then asks if I am sure (again!!) then says I need permission to delete a folder I only just created.

FUCK OFF!!

Vista - looks nice. Works like an arse.

23rd of July, 2008@10:52:02 PM
add a comment, permanent link to article
[filed under Programming]PHP Closeures

PHP 5.3 has closures in it! Finally we get some good stuff to play with: PHP 5.3 and Closures. This is excellent news, even if the closures look weird -- look at the strange use keyword.

 

22nd of July, 2008@11:33:41 AM
add a comment, permanent link to article
[filed under Programming]Zend Framework DB Insert NOW

Some keywords: SQL Insert Update Zend_Db_Table_Row NOW() now function Zend_Db_Table Zend_Db_Expr

Use the SQL function NOW() in ZF:

$k = new My_Table();
$row = $k->createRow();
$row->datetime        = new Zend_Db_Expr('NOW()');
$row->save();

This works because DB Expr doesn't escape the string 'NOW()'. Yay.

15th of July, 2008@3:29:22 PM
add a comment, permanent link to article
[filed under Programming]Why LISP is better than me

I wish I could do this in any of the languages I use: porting-perls-qq-to-common-lisp. A few simple lines of code and you have a new language operator qq. Ugh. This would be soooo cool.

I had a problem the other day where I had an object with various members, some of which I wanted to have the extra attribute 'merge-able' some how. This is how it looked:

class moo{
  private var colour:String;
  protected var depth:Number;
  public var height:Number;
  .....

Then in a method inside moo:

foreach( prop in this )
{
  // this iterates over 'colour','depth','height'

and what I wanted was to somehow 'hide' height from the iterator...

I guess there are two ways of doing this, first override the 'iterator' or 'foreach' operator. This is impossible in ActionScript. Or second add an attribute to each property, kinda like:

class moo{
  private var colour:String;
  protected var depth:Number;
  public non-iterable var height:Number;
  .....

But there's no way to do this and no way to extend the language to make it work. It is most irritating.

I have 40 or 50 objects and I iterate over all of them. And I have this problem in one or two of them.... argh! How annoying.

The only thing I can think of is to have an iterable properties list, then:

foreach( prop in this.iterable_properties_list() )
{
  // only returns 'colour' and 'depth'
  this[prop] = ....

But this means keeping my object definition and iterable_properties_list method in sync (for over 40 different objects.) Filth.

I guess I could hack it using PHPs naming scheme, anything that starts with an underscore is 'special'. Then I could do:

foreach( prop in this )
{
  // this iterates over 'colour','depth','_height'
  if( !prop.starts_with('_') )
    // _height is magically hidden...
    ....

But then I need to rename all my properties in all my objects. Bah. I want language macros! And I want them now!! :-)

8th of July, 2008@3:03:03 PM
add a comment, permanent link to article
[filed under Programming]Larrabee new Intel chip

Shit! The new intel chip, Larrabee has 32 cores! Core me up y'all.

8th of July, 2008@1:11:33 PM
permanent link to article
[filed under Programming]a better type of php

Some interesting links about PHP. PHP 6 may use the Parrot virtual machine to run. That would be very interesting, for example when the Perl guys port CPAN to Parrot, PHP would have access to that vast, vast library of code.

Compiling PHP to Parrot (or .NET or Java) would speed up the code, reduce the memory consumption and just make everything much more nicer. But until we get that, there are a few PHP op-code cachers and PHC a PHP compiler. Sweet.

7th of July, 2008@2:23:52 PM
add a comment, permanent link to article
[filed under Programming]Python csv NULL BYTE fail re regex split

My problem is that I have a csv file that Python can't read because it has NULL bytes in it. Python has a built in csv reader, but this chokes and dies :-(  (booo)

Problem 2: line.split(',') also chokes because some lines look like this:

1,2,"3,4,5",6

which have to split into 4 items. Ack. I thought I was going to have to write a little finite state machine (which I like doing) but my csv file is 18meg. So fsm may = slowness.

After some searches I came across this funky bit of regex that I made into even funkier Python:

>>> subject = """1,2,3,"4444","55,55,,,,55",99"""
>>> splitter = re.compile(r',(?=(?:[^"]*"[^"]*")*(?![^"]*"))')
>>> splitter.split(subject)
['1', '2', '3', '"4444"', '"55,55,,,,55"', '99']

:-)

wtf? I'm not sure what is going on, I got lost at "Assert that it is impossible to match the regex below starting at this point (negative lookahead)" hmmm. Yes. Magic.

2nd of July, 2008@3:57:27 PM
add a comment, permanent link to article
[filed under Programming]Zend Framework Ajax

You need to turn off the layout renderer and the view renderer:

public function busyAction()
{
    //
    // turn off the view helpers
    //
    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
    //
    //
    //
    $tmp = array( 'test'=>'value' );
    echo Zend_Json::encode($tmp);
}

Then use Zend_Json to encode your values and output them.

For the client side I suggest you grab jQuery or prototype to make things easier.

2nd of July, 2008@9:04:10 AM
add a comment, permanent link to article
[filed under Programming]More Linux Tips

More shell commands that we all should know.

Step 1 of becomming a better programmer is to look at your tools and find out 1 new thing that it/they can do. Then use that function.

30th of June, 2008@11:45:56 AM
add a comment, permanent link to article
[filed under Programming]OMeta

Wanna see the future of programming? Check out OMeta, it allows you to extend your language to include your own instructions. Neat.

For example, in my code I am forever looping over dates. I may display every day this month, or every week this quater or every month this year. Wouldn't it be cool to extend the language to have this ability built into it?

I'd extend foreach( $vars as $var ) and make it foreachmonth( $date_range as $month ) it may not be that useful, but that tiny bit of syntatical help would be worth the effort of extending the language.

The way python is able to loop through a list and do something with each element:

tmp = [x*2 for x in list]

is so cool it needs to be built into PHP. Take a look at how macros are built in nemerle, scroll down to the for loop. They add c style for loops to the compiler. I want to do this in PHP. Domain specific mini languages are the future.

24th of June, 2008@12:16:23 PM
add a comment, permanent link to article
Unique hits [] : Total hits [] : Server Grind [0.4045 seconds]