Archive for January, 2010
top != self and fun with the Tokelauans
I noticed recently that THE GREATEST SITE IN THE WORLD had a new referrer. I checked it out, and saw this:
A touch of JavaScript, and now they see this:
Just say NO to frames. And kiwis.
January 26, 2010
Posted in: javascript, rants
No Comments
string.Format() in PHP
.NET’s sprintf() equivalent has ordered parameters.
var s = string.Format("My name is {1}, {0}", "Tommy", "Montgomery");
//s = "My name is Montgomery, Tommy"
var s = string.Format("My name is {{{0}}}", "Tommy");
//s = "My name is {Tommy}"
I needed that. Here it is, PHPified:
function format($format) {
$args = func_get_args();
$format = array_shift($args);
preg_match_all(‘/(?=\{)\{(\d+)\}(?!\})/’, $format, $matches, PREG_OFFSET_CAPTURE);
$offset = 0;
foreach ($matches[1] as $data) {
$i = [...]
January 9, 2010
Posted in: c#, php
No Comments
Intro to Functional Programming via JavaScript
This is purely an academic exercise. Adam contacted recently with a link to a blog post on implementing the Y-combinator in JavaScript. There were a whole bunch of words that sound smart, such as
Recursion
Fixed point
Y-combinator
Memoization
It’s like a professor’s dream come true. I had seen the article a long time ago when I prepared a presentation [...]
January 2, 2010
Posted in: javascript
No Comments
