Archive for November, 2009
Eid Mubarak
Eid Mubarak for all my brothers and sisters out there!
Using PHP callback functions in array_walk in a class.
Ran into something small that might be helpful for other PHP types. This isn’t rocket science, but I don’t see enough examples with static function calls for these functions.
array_walk lets you call a function that will be iterated over all members of an array. In my template class, I had to append some text to the front and back of a search variable. Instead of using the poorly performing foreach loop, I just ran the array_walk function and passed it a function that did the same thing.
array_walk($search, 'template_variable');
I decided that this was not what I wanted (since template_variable would be defined as a function in the global context), and I preferred putting related functions in the same class. I tried this:
array_walk($search, 'self::template_variable');
Of course, this didn’t work. array_walk is not a member of the Template class and as a result it just threw an error stating that “self::template_variable” didn’t exist.
array_walk($search, 'Template::template_variable');
This works fine.
-edit-
There’s something weird and inconsistent about all of this. template_variable works even while private, which throws everything out of wack.
Finally light is in sight.
I’m delighted that this rescue mission on my T’s restaurant website contract is nearly done. Months of effort on something that was supposed to only take 2 weeks. At least he promised me that he’d consult with me before making any more impossible schedules. :hmm:
Fun Time at Kebab-Ye Yesterday
I went to dinner at my favourite Kebab place yesterday with local Tokyo socialite/photographer (and awesome dude) Christopher Jue. I had originally planned on making small talk, when I ran into my friend Syed Hatoyama. The three of us started talking when a stylish girl walked into the store. She seemed to know Syed, and I started poking him about their relationship; he was visibly shaken and told me in a quiet voice that her boyfriend was in the store. The big guy had a sense of humor and we exchanged pleasantries before I got back to talking to Chris.
The weird thing happened about 15 minutes later. I had forgotten to remove Taluva from my backpack, and I suddenly realized there were just enough people to play the game. I pulled out the box and yelled “Hey dude, wanna play?” in Japanese to the two strangers (and Syed as well). Oddly enough, they concurred (as long as they could play as a team) and off we went.
Turns out the girl was a Japanese champion at Karate, and the guy was a math major / Karate blackbelt himself. He was a quick learner too; he won the game handily on his first go at it. We traded emails and I told him to come by anytime.
I don’t know why I’m even blogging this, except for the fact that this was the first time I had such a spontaneous event in Tokyo and this socializing through board gaming thing actually worked. (For those who aren’t in the know, I brought board games to Tokyo with me because a few of the guests at my house parties seemed to have a hard time talking to the other guests; light gaming seemed to be a good ice breaker to me.) I’m going to try this more often, maybe at the local Starbucks or something.
Butter Chicken Recipe
I’m cooking Butter Chicken today at the Tokyo Hackerspace. For your entertainment, here is the recipe & information if you want to try it yourself.