Saturday, June 13, 2009

Trim .wav file in ubuntu

1. Install sox command. If don't have it, you can install it by "sudo apt-get install sox"
2. Use sox command with option trim
sox [input file] [output file] trim [from time] [to time]
Example: sox OverviewPart1.WAV Overview.wav trim 0:10 1:21

Solving Desktop effectes could not be enabled

When we use ubuntu, we may want to enable desktop effects because it allows us to do many things such as zoom in and zoom out. We can try to enable desktop effects by going to System > Preferences > Appearance > Visual effects and then click "Normal" or "Extra"

try to enable desktop effects on ubuntu but get the problem "Desktop effects could not be enabled", try to do the following steps:

1. Use command compiz and then you may find out that your video driver is in the blacklist as shown in this picture
2. edit /usr/bin/compiz and put the # at the line that has your video driver specification so that it is not in the black list
Now, try to enable Desktop effects again. You should be able to enable it now :)

Recommended plugins for firefox

There are many plugins for firefox, but we should not install all of them because they may downgrade the performance of firefox.

These are recommended plugins for firefox

1. Adblock Plus - to block all advertisement messages
2. Delicious Buttons
3. Noscript
4. SmarterFox

Saturday, April 14, 2007

Sample PHP Codes Call Amazon Web Services

<?php
// callAmazonRESTWS.php
header("Content-type: text/xml");
$base = 'http://webservices.amazon.com/onca/xml';
$query_string = '';
$params = array(
'Service' =>'AWSECommerceService',
'SubscriptionId' => '16XT8ETKKB7NWHAGCQ02' ,
'Operation' => 'ItemSearch',
'SearchIndex' => 'Books',
'Keywords' => 'Web Services');

foreach ($params as $key => $value) {
if ($key != 'Keywords')
$query_string .= "$key=" . urlencode($value) . "&";
else
$query_string .="$key=".urlencode($value);
}
$url = "$base?$query_string";

// Define a context for HTTP.
$aContext = array(
'http' => array(
'proxy' => 'tcp://202.12.97.116:8080', // This is the sample server and the port of the proxys server.
'request_fulluri' => True,
),
);
$cxContext = stream_context_create($aContext);
// Now all file stream functions can use this context.
$xml = file_get_contents($url, False, $cxContext);
echo $xml;
>



You will get the result as shown on this picture.
















References


* Roger L. Costello, “Building Web Services the REST Way”, http://www.xfront.com/REST-Web-Services.html
* Stefan Marr, “RESTful Web Services”, HPI, Seminar Advanced Database Technology
* Pete Freitag, “REST vs SOAP Web Services”, http://www.petefreitag.com/item/431.cfm
* Google, “Google SOAP Search API”, http://code.google.com/apis/soapsearch/
* Sameer Tyagi, “RESTful Web Services”,
http://java.sun.com/developer/technicalArticles/WebServices/restful

Automatically Backup MySQL Databases on Linux Server

We can automatically backup MySQL database on linux server by writing script and run cron. The cron command can run the script every x day at time y. The script use mysqldump in back up the database

The sample procedure is as follows

1. create script mysqldump.bsh which has it content as

#!/bin/bash mysqldump –user=”Database Username” –password=”Database Password” –all “Database Name” | gzip > “Full Path Where You Want Backup Saved”-`date +%Y%m%d`.gz

2. create file cron.txt

Assume that we want to backup the database at 6 am everyday

0 6 * * * /path/to/your/mysql_dump.bsh

There must be an empty line before the end of the file

3. run command "crontab cron.txt" to start the jobs specified in cron.txt

4. run command "crontab -l" to see the list of jobs currently scheduled and run on the system


References

http://www.bloggingpro.com/archives/2004/05/28/backing-it-up-or-lose-it/


http://en.wikipedia.org/wiki/Crontab

http://www.adminschoice.com/docs/crontab.htm