Category Archives: Tweak

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

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

tpcc-mysql rough benchmark for Amazon RDS

I tried to do tpcc-mysql benchmark for Amazon RDS. Before do that, did the same test for EC2 small instance. From EC2 small instance to small. Fedora8 and MySQL 5.0.45. Default configuration. (no change for a my.cnf; innodb_buffer_pool_size = 8388608) # mysql -h domU-12-31-39-06-7C-86.compute-1.internal -u mymasteruser -p mysql> grant all privileges on tpcc.* to tpcc@'%' identified by [...]
Posted in Tweak | Tagged , | 1 Comment

Amazon RDS quick start

I’ve tried to use Amazon Relational Database Service. Easy to scale-up appeals to me. Official Getting Started Guide is very good. I almost followed this document. Works on Mac OSX 10.5.8. % rds-create-db-instance --db-instance-identifier myinstance --allocated-storage 5 --db-instance-class db.m1.small --engine MySQL5.1 --master-username mymasteruser --master-user-password **** --db-name MyDatabase --headers It takes several minutes. % rds-describe-db-instances --headers Unable to find a $JAVA_HOME [...]
Posted in Tweak | Tagged | Leave a comment

rackspacecloud.com’s Cloud Files network benchmark

I got a rough benchmark. Main purpose is to know how Cloud Files(rackspacecloud.com) is fast from Tokyo, Japan. Also I compared the speed with Amazon EC2/CloudFront and Sakura Internet 7,800yen dedicated hosting service. % ab -n 50 -c 5 http://server/image-file(jpg/png/gif) Transfer rate (Kbytes/sec): 1527 (www.google.com) 1245 (s3.amazonaws.com) 3796 (cloudfront.net) 45 (sakura internet 7800yen server) 2135 (cdn.cloudfiles.rackspacecloud.com) 42 (rackspacecloud cloud server mem 256M) @San Jose, CA [...]
Posted in Tweak | Leave a comment

Using MAMP is better than source compile PHP on Mac OS 10.5.8

PHP5.2.10 couldn’t be compiled on Mac OS 10.5.8. % ./configure --with-readline --with-mysql --with-pdo-mysql --enable-mbstring --with-openssl --with-curl --with-apxs2=/usr/local/apache2/bin/apxs % make Undefined symbols: "_EVP_CIPHER_CTX_block_size", referenced from: _zif_openssl_seal in openssl.o ld: symbol(s) not found collect2: ld returned 1 exit status make: *** [libs/libphp5.bundle] Error 1 I tried to compile openssl0.9.8j, then set –with-openssl=/usr/local/ssl, but the same error occurred. –with-openssl=shared works [...]
Posted in Tweak | Leave a comment

Back up Gmail Starred with fetchmail and procmail

% fetchmail --all --proto IMAP --port 993 --user *your gmail account name* --ssl --folder '[Gmail]/Starred' --mda "/usr/bin/procmail -d %T" --keep imap.gmail.com You can get mails at /var/mail/*your mac account name*. On Mac OSX 10.5.5.
Posted in Tweak | Tagged | 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