Author Archives: Nobu

jQuery plugin for Twitter OAuth via popup window (Facebook style)

Disqus and some applications are using Twitter OAuth, but their user flow is not sequential single window process. A child window comes up, then it shows twitter.com and user can click Deny/Allow through that popup. When the user hits the deny or allow button, the popup will be closed immediately and the parent window will [...]

Posted in Create | Tagged , , , , | 17 Comments

How to Make an Autobot on Twitter with OAuth, not Basic Authentication

Twitter will be shutting off basic authentication on their API on June 30. Tweeting with basic auth was pretty easy in PHP: $context = stream_context_create(array( ‘http’ => array( ‘method’ => ‘POST’, ‘header’ => ‘Content-type: application/x-www-form-urlencoded’, ‘content’ => http_build_query(array(’status’ => $status)), ), )); $response = file_get_contents("http://$username:$password@twitter.com/statuses/update.xml", false, $context); After shut off basic auth, how can we [...]

Posted in Tweak | Tagged , , , | 2 Comments

Crowd-Reward: Encouraging Passion, Building Communities

As a cofounder of Senzoo.net, I’d love to talk about it. We want to follow our own philosophy and be the first company that pays its employees by a crowd-rewarding system, where users’ contributions make up the employee’s salary. At the same time, we are offering a crowd-rewarding system called Senzoo. We want to prove [...]

Posted in Think | Tagged | Leave a comment

Compiling PHP5.3.2 on MAMP

It was not easy to compile PHP5.3.2 on MAMP. First of all, you need to download httpd2.0.63 and PHP5.3.2. (I’m using MAMP 1.8.2 and Mac OSX 10.5.8) MAMP is in /Application/MAMP already. You may want to backup that directory. You may need to edit srclib/apr/include/apr.h like “#define APR_HAS_SENDFILE 0″ after run configure because get an [...]

Posted in Tweak | Tagged , , | 3 Comments

jQuery validation: required and minlength for dynamic fields

This is not a smart way though, but I tried to code for a bit complexed form. Demo. Code snippet: $(’form input[type=button]‘).click(function(){ $(’ul’).show().append(’<li><input class="hidden" type="checkbox" name="list[]" value="1" checked="checked" />’ + $(’select[name=item_name] option:selected’).html() + ‘&nbsp;’ + $(’select[name=price] option:selected’).html() + ‘&nbsp;<a>remove</a></li>’); $(’ul li a’).click(function(){ $(this).parent().fadeOut(’slow’, function(){ $(this).remove(); }); }); }); var validator = $(’form’).validate({ rules: { ‘list[]‘: [...]

Posted in Tweak | Tagged , | Leave a comment

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

Sending git notifications via Gmail SMTP server

Hosting SMTP server like sendmail/postfix by yourself is a bit high cost and emails easily go to spam folder if you don’t setup DNS stuff. Instead, let’s use Gmail SMTP server to send notification emails from git. You need to edit post-receive-email a bit. send_mail() { # if [ -n "$envelopesender" ]; then # /usr/sbin/sendmail [...]

Posted in Tweak | 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 long 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 “G is null”. You can’t pass null [...]

Posted in Tweak | Tagged , | 2 Comments

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) } } Then, simply this one liner works well. $multipleArray = array_map(’get_object_vars’, $complexedObject); Since [...]

Posted in Tweak | Tagged | Leave a comment