Monthly Archives: January 2010

Bracket auto completion in vim for PHPer

I used to use this setting in .vimrc: inoremap \( ( inoremap ( ()<LEFT> But escape bracket every time for second\(first(); is a little bit stressful. (typed “first()”, then move to the head of the line, typing “second”, back slash and bracket) Here is an improved script: function! CompleteDetachedBracket() let line = line('.') let col = [...]
Posted in Create | Tagged | Leave a comment

Convert multiple object to array in PHP

For simple object, just use cast syntax should be fine. $array = (array)$object; However, this way doesn’t work for complexed object (or array+object combination) like this: array(2) { [0]=> object(stdClass)#1 (1) { ["id"]=> int(0) } [1]=> object(stdClass)#2 (1) { ["id"]=> int(1) [...]
Posted in Tweak | Tagged | Leave a comment

Complete working sample for Services_Twitter OAuth in PHP PEAR

% pear install --alldeps Services_Twitter-alpha You can get some sample codes for Services_Twitter with OAuth from php doc, but it’s not a complete code. I rewrite some parts. <?php if (isset($_GET['clear'])) { // sometimes you need to clear session, just access ?clear=1 session_start(); $_SESSION = array(); session_destroy(); [...]
Posted in Tweak | Tagged , , , | Leave a comment

Compiling mongo php driver on pecl for MAMP

MAMP 1.8.2 includes pecl but actually it doesn’t work. When trying to “pecl install mongo”, there will be an error. grep: /Applications/MAMP/bin/php5/include/php/main/php.h: No such file or directory So, I downloaded source tar ball of PHP 5.2.10 (same version as MAMP’s PHP) and configure && make && make install. Then $prefix/include directory will be created. Just copy them [...]
Posted in Tweak | Tagged , , | 1 Comment
  • About

    I'm Nobu, a web developer living in Mountain View, CA. Feel free to comment on any posts. I'm also tweeting on twitter.

  • Archives

  • Recent Posts