Author Archives: Nobu

Short review for Nexus One + Verison Mifi

I’m using Nexus One without SIM card, and Mifi from Verison in a couple of weeks. I used to use iPhone 3G in Tokyo (sadly, it was SIM locked, I can’t use it in the US), comparing two but it’s hard to say which one is better. Mostly I use default applications like browser, email [...]
Posted in Think | Leave a comment

git post-receive-email with php using GMail SMTP

Hosting SMTP myself is a bit high cost. It’s a good solution to use GMail SMTP server. I changed post-receive-email a bit. send_mail() { # if [ -n "$envelopesender" ]; then # /usr/sbin/sendmail -t -f "$envelopesender" # [...]
Posted in Uncategorized | Leave a comment

Get error message “G is null” or “a is null” on jQuery

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ var obj = null; // ...maybe there are complexed lines... $.each(obj, function(){ }); }); </script> Will get an error message “a is null”. When using jquery.min.js, it might be hard to recognize what kind of error it is. On version 1.3.2 the message says [...]
Posted in Tweak | Tagged , | Leave a comment

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

Load remote CSS file dynamically with jQuery

These codes are for dynamic loading for remote CSS. It’s easy to load all CSS files from the beginning or just append link element (ref. Switch stylesheets with jQuery). But it rarely needs to load a file dynamically and wait until CSS file has been loaded completely. test.html: <html> <head> <title>css.html</title> <script src="/jquery-1.3.2.js"></script> <script> $(document).ready(function() { // if [...]
Posted in Tweak | Tagged , , | Leave a comment

Catch Up On The News Mashup For Social Media

“Catch Up On The News” is a mashup for social news media such as digg, tweetmeme, techmeme and delicious. It is showing top 20 popular articles from yesterday, last week or whenever you can specify. Do you have an experience that after finishing a vacation, would like to read a week’s news all at one time? [...]
Posted in Create | Tagged , | 1 Comment

Call a method of object with string in JavaScript

var call_user_func = function(obj, method) { return eval('obj.' + method).apply(obj, Array.prototype.slice.call(arguments, 2)); } var test1 = { method1: function(arg1, arg2, arg3) { return alert(arg1 + arg2 + arg3); } } call_user_func(test1, 'method1', 1, 2, 3); It works on Firefox3, Safari4, IE6.
Posted in Uncategorized | Leave a 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