Alexey Zakhlestin's Blog

Programming for Mac and Web

I Love Open-source

Permalink

I made several patches to PHP-extension part of syck library (YAML parser). From now on, it should:

  • compile successfully on MacOS-X

  • compile successfully in ZTS-enabled environment

  • not crash php-process anymore, on parse errors

  • throw SyckException on parse errors

You can checkout latest version from WhyTheLuckyStiff’s SVN here: http://code.whytheluckystiff.net/svn/syck/trunk/ext/php/

Mozilla Will Support Http-only Cookies

Permalink

A patch for [Bug 178993] MSIE-extension: HttpOnly cookie attribute for cross-site scripting vulnerability prevention has just been committed to mozilla’s CVS. It is not yet approved for inclusion in 1.8-branch, but trunk will have it since now.

This will help to solve some of XSS-vulnerabilities related problems

update: the patch was removed from tree, for now, but looks like it will be back soon, after passing several bureaucratic procedures

Sun Optimized AMP Stack for the Solaris 10 OS

Permalink

Sun Optimized AMP Stack for the Solaris 10 OS .

Sun offers a new recipe for success — the Solaris OS + AMP (Solaris 10 OS, Apache, MySQL, and PHP). For customers committed to the open AMP stack, this “recipe” provides the same Web applications they know and use, but on a more secure open-source platform with greater scalability. Sun provides complete step-by-step instructions to get up and running more quickly when building and deploying Web applications. Sun offers five easy steps to quickly develop Web applications.

Developer support for this optimized “stack” is supposed to start in march.

p.s. I wonder, if 2007 is going to be the year of Solaris…

Macfuse

Permalink

Something, many of us were waiting for a long time: macfuse

I am quoting original site:

MacFUSE implements a mechanism that makes it possible to implement a fully functional file system in a user-space program on Mac OS X. It aims to be API-compliant with the FUSE (Filesystem in USErspace) mechanism that originated on Linux. Therefore, many existing FUSE file systems become readily usable on Mac OS X. The core of MacFUSE is in a dynamically loadable kernel extension. Moreover, the FUSE user-space library needs a few minor changes to work on Mac OS X.

Currently, the only implemented filesystem is sshfs

After installing, you should issue the following command in terminal to mount some remote system: mkdir ~/test_mount sshfs login@remote.computer.com:/remote/path ~/test_mount

On Documentation

Permalink

People often debate on reasons of PHP’s success and “not so big success” of it’s more powerful competitors. My belief is, that one of the major parts of PHP’s win was it’s manual. All of the competitors had basic API documentation, but they didn’t have:

  • syntax-highlighted examples for the majority of functions
  • user-contributed comments

It’s actually getting better now (see documentation on Ruby’s CGI module, for example). But no-one is close enough.

One of the main concerns of the language core-team should be documentation. Better the docs are, more people will be comfortable to start using it for solving their problems.

If I have several weeks for digging into sources, I will probably chose the language which I like syntactically. But if the timeframe if small, I would definitely prefer the one which has better docs. Guess which situation tends to happen more often.

Something to think about:

Trac for Haskell

Permalink

Trac is one of the best things which happened to open-source software. But that is not news, really.

The good news is, that haskell software community started to adopt Trac for their needs too. One of the examples is MissingH library. The reason of “tracification” is simple: there is a stable darcs plugin available for trac

Regexps in PHP, Again

Permalink

People keep on insisting, that preg_match is better for non-unicode lookups than mb_ereg. So, here are actual benchmarks to make it clear.

Here are results:

1
2
3
preg_match:      19.8039090633
mb_ereg:         15.9386620522
mb_ereg_search:  1.24934506416

Here is the source:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
$regexp = '[\w]+@[\w]+\.com';
$pcre_regexp = '/'.$regexp.'/';

$regexp2 = '[\s]+@[\s]+\.com';
$pcre_regexp2 = '/'.$regexp2.'/';

$text = 'blabla bla blbaaasdajkln dsfkl klewnjklfnjkne qwe123@gg.net adkljaskdlnkljnasdljk qwe@test.comasdjlajnsdklnasdklnjl';

$t1 = microtime(true);
for ($i = 0; $i < 100000; $i++) {
    $res1 = preg_match($pcre_regexp, $text);
    $res2 = preg_match($pcre_regexp2, $text);
}
$t2 = microtime(true);

$t3 = microtime(true);
for ($i = 0; $i < 100000; $i++) {
    $res3 = mb_ereg($regexp, $text);
    $res4 = mb_ereg($regexp2, $text);
}
$t4 = microtime(true);

$t5 = microtime(true);
mb_ereg_search_init($text);
for ($i = 0; $i < 100000; $i++) {
    $res5 = mb_ereg_search($regexp);
    $res6 = mb_ereg_search($regexp2);
}
$t6 = microtime(true);


echo 'preg_match:      '.($t2 - $t1)."\n";
echo 'mb_ereg:         '.($t4 - $t3)."\n";
echo 'mb_ereg_search:  '.($t6 - $t5)."\n";

Feel free to check it out yourself.