Category Archives: Tweak

Jasmine install memo

Jasmine + Sinon.JS looks neat. I just tried to play around on Amazon AMI. yum install ruby-devel rubygems gem install rspec-expectations gem install rake cd working-directory cd tests jasmine init rake jasmine your-laptop:% ssh sandbox -L 10000:127.0.0.1:8888 Access http://127.0.0.1:10000/ from your browser.

Posted in Tweak | Comments closed

Unexpectedly got a grayscale video on ffmpeg

When I encode a video from jpeg to avi or something, I get this message: % ffmpeg -f image2 -i foo-%03d.jpg foo.avi Input Stream #0.0 frame size changed to 680×420, yuvj444p and the video will be grayscale unexpectedly. When I make jpeg images from png with ‘convert’ (which is ImageMagick command) a blank/black image becomes […]

Posted in Tweak | Comments closed

Compiling httpd-2.2.16 and php-5.3.3 on Mac OS X 10.6.4

Probably because of upgraded ports packages, self-compiled PHP on MAMP suddenly became not to find libjpeg and some libraries. There’s a way to upgrade to MAMP1.9, but I’ve decided to switch to use self-compiled 64bit PHP. Removed all macports packages. http://trac.macports.org/wiki/Migration % sudo port -f uninstall installed % sudo port clean –work –archive all For […]

Posted in Tweak | Tagged , , , | Comments closed

Screenshots for UIKeyboardType

iPhone has several keyboard types: typedef enum { UIKeyboardTypeDefault, UIKeyboardTypeASCIICapable, UIKeyboardTypeNumbersAndPunctuation, UIKeyboardTypeURL, UIKeyboardTypeNumberPad, UIKeyboardTypePhonePad, UIKeyboardTypeNamePhonePad, UIKeyboardTypeEmailAddress, UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable } UIKeyboardType; I took the screenshots for them.

Posted in Tweak | Tagged | Comments closed

Don’t define json_encode with Zend_Json

Some web servers are still working with PHP5.1.6. That means json_encode/json_decode is not supported by default. Although some libraries are using json_encode, for instance php-sdk for facebook, so I defined json_encode like this: function json_encode($data) { return Zend_Json::encode($data); } I didn’t know that actually Zend_Json uses json_encode in their code, so badly it will be […]

Posted in Tweak | Tagged | Comments closed

[Unsolved] Got “Peer certificate cannot be authenticated with known CA certificates” while using Twitter OAuth with PHP PECL_OAuth

Here is a dump for $oauth->debugInfo. ($oauth is an OAuth class from PECL_OAuth) array(2) { [“sbs”]=> string(240) “POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_consumer_key%3***%26oauth_nonce%3D16905507154beeed8c5ce2d0.02323759%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1273949580%26oauth_version%3D1.0” [“info”]=> string(537) “About to connect() to api.twitter.com port 443 (#0) Trying 128.242.245.125… connected Connected to api.twitter.com (128.242.245.125) port 443 (#0) SSLv3, TLS handshake, Client hello (1): SSLv3, TLS handshake, Server hello (2): SSLv3, TLS handshake, CERT (11): […]

Posted in Tweak | Comments closed

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:[email protected]/statuses/update.xml", false, $context); After shut off basic auth, how can we […]

Posted in Tweak | Tagged , , , | Comments closed

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 , , | Comments closed

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 , | Comments closed

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 | Comments closed