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
-
add-on amazon rds applescript cocoa css firefox gmail javascript jquery mac mamp mashup mongo mysql oauth Open Tab-History In New Tab pear php skype social SweetCatcher twitter vim
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
-
Recent Posts
-
Blog under the Creative Commons Attribution 3.0 License
Category Archives: Tweak
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)
[...]
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();
[...]
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 [...]
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 [...]
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 [...]
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 [...]
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.
Get error message “G is null” or “a is null” on jQuery