7 Simple Steps to create Twitter Application

First you have to download oAuth from github

“An open protocol to allow secure API authorization in a simple and standard method from desktop and web applications.”

7 Simple Steps to create Twitter Application using Twitter’s OAuth….

1. Build TwitterOAuth object

Login to twitter and register a new application here https://twitter.com/oauth_clients … after registering application save consumer key and consumer secret.

$to = new TwitterOAuth($consumer_key, $consumer_secret);

Twitter OAuth

2. Request tokens from twitter

$tok = $to->getRequestToken();

3. Build authorize URL

$request_link = $to->getAuthorizeURL($token);

4. Send user to Twitter’s authorize URL

Twitter_1268502547513

5. Get access tokens from twitter

$tok = $to->getAccessToken();

6. Rebuild TwitterOAuth object

$to = new TwitterOAuth($consumer_key, $consumer_secret, $user_access_key, $user_access_secret);

7. Query Twitter API with new access tokens

$content = $to->OAuthRequest(‘https://twitter.com/account/verify_credentials.xml’, array(), ‘GET’);

$content = $to->OAuthRequest(‘https://twitter.com/statuses/update.xml’, array(‘status’ => ‘Test OAuth update. #testoauth’), ‘POST’);Twitter - Redirecting you back to the application_1268502564768

Source:
https://docs.google.com/View?docID=dcf2dzzs_2339fzbfsf4
http://wiki.github.com/abraham/twitteroauth/links

Install PECL Memcache with LAMPP

PECL Memcache client of memcached distributed cache server, is a very probable candidate for high-load systems.
Typically you won’t be able to use “pecl” directly and when you try to install manually with phpize you will get an error like:

” PHP Warning: Unknown(): Unable to load dynamic library ‘/opt/lampp/lib/php/extensions/no-debug-non-zts-20020429/memcache.so’ – /opt/lampp/lib/php/extensions/no-debug-non-zts-20020429/memcache.so: undefined symbol: OnUpdateLong in Unknown on line 0″

Below is step-by-step guide of how to install a PECL extension (Memcache in this case) in the latest XAMPP:

make sure you uninstall all and any PHP installations you may have had before along with PECL and PEAR

Download and install XAMPP 1.7.1

Add /opt/lampp/bin to your PATH

Download and install XAMPP Development Package

backup /opt/lampp/include directory to /opt/lampp/include-bak. This directory

Download source distribution of the PHP corresponding to your XAMPP installation

php source distribution is /opt/lampp/include/php

Run “./configure” and “make” on that php source.

Caution: Do NOT run “make install”!!!

Download memcache-2.1.2 anywhere

# cd memcache-2.1.2

# phpize

# ./configure

# make

# make install

Edit /opt/lampp/etc/php.ini and add a line:

extension=”memcache.so”

Knowledge speaks, but wisdom listens. 😉

No route to host

Often, when we get error “No route to host” to connect remote server via linux command line e.g. wget, curl etc. or web services (webserviceserver).

The first solution we want to try to troubleshot firewalls and proxies?

But before that try hostname entry in linux box…

# vi /etc/hosts
add & save
192.168.0.100 webserviceserver

If still experienced the issue when deploying code from development machine to a live server.

Ping other servers like
# ping google.com
# wget http://www.google.com

If ping & wget working for google means the webserviceserver have some block or restrictions to calling servers.

Make sure with several linux network utilities

# nc webserviceserver.com 8080
webserviceserver.com [192.168.0.100] 8080 (www) : No route to host

# telnet 192.168.0.100 8080 (working?)

# traceroute www.webserviceserver.com (working?)

# ping www.webserviceserver.com (working?)

Make sure firewall is not blocking your access:
# /sbin/iptables -L -n
# /etc/init.d/iptables save
# /etc/init.d/iptables stop

# iptables -F
# iptables -X
# iptables -t nat -F
# iptables -t nat -X
# iptables -t mangle -F
# iptables -t mangle -X

Make sure we are using a router and not a proxy server. Proxy servers are good for Internet browsing but not for ftp, sending ICMP request and so on.

Try on alternate port..
# nc webserviceserver.com 8078

If this is working then we have to use alternate port for the server “webserviceserver.com”

Make alternate port for network connection 🙂

Install swftools

SWFTools is the utilities for working with Adobe Flash files. These tools includes programs for reading SWF files, combining them, and creating them from other content (like images, sound files, videos or sourcecode).

Install SWFTOOLS:
Download latest Sourcecode from here…
http://swftools.org/download.html

# wget http://swftools.org/swftools-0.9.0.tar.gz
# tar -zxvf swftools-0.9.0.tar.gz
# cd swftools-0.9.0

# ./configure
# make

Some time make generate errors for xpdf.. so we have to install xpdf here….
Search for “xpdf-3.02.tar.gz” download & install

# cd lib/pdf
# wget http://gd.tuwien.ac.at/publishing/xpdf/xpdf-3.02.tar.gz
# perl inject-xpdf.pl xpdf-3.02.tar.gz

Then…

# make clean
# make
# make install

Here we successfully installed swftools for all swf related operations.
We can find all linux utilities in src for of “swftools-0.9.0” like

* as3compile
* font2swf
* gif2swf
* jpeg2swf
* pdf2swf
* png2swf
* swfbbox
* swfc
* swfcombine
* swfdump
* swfextract
* swfrender
* wav2swf

SWFTools has been reported to work on Solaris, Linux (both 32 as well as 64 bit), FreeBSD, OpenBSD, HP-UX, Solaris, MacOS X and Windows 98/ME/2000/XP/Vista.

Magento make easy – part1

Magento
Create a dynamic, fully featured, online store with the most powerful open source e-commerce software….

Download Magento from here..
http://www.magentocommerce.com/svn

# svn checkout http://svn.magentocommerce.com/source/branches/1.3

Features..

1. Categories and Attributes
2. Taxes
3. Adding Simple Products
4. Minimum Customization of Your Store’s Appearance
5. Customer Relationships / Configuring customer options
6. Accepting Payment
7. Configure Shipping
8. Fulfilling an Order

The list of requirements..

Linux, Apache web server, SMTP server, PHP 5.2.0 or newer with PDO/MySQL, mcrypt, hash, simplexml, GD, DOM, iconv, MySQL 4.1.20 or newer

Installation guide here…

Make the store’s appearance and organization..
* Add products
* Categorize products
* Create a navigation menu
* Configure payment options
* Configure shipping options
* Configure taxes
* Customize the front page
* Process orders

Magento make easy – part2 comming soon 😉

Backup mysql database to amazon S3

Below is the simple code to create sql script of database on Amazon EC2 server using “mysqldump”…

then upload this sql script to Amazon S3 bucket using command line S3 tool “s3cmd”…


<?php

$sqlbackup="/usr/bin/mysqldump -v -u root -h localhost -r /var/www/html/backup/".date("Y-m-d-H-i-s")."_db.sql -pdbusername  databasename 2>&1";

exec($sqlbackup$o);

echo 
implode("<br /> "$o);

$file "/var/www/html/backup/".date("Y-m-d-H-i-s")."_db.sql";

$bucket "s3bucketname";

exec("/usr/bin/s3cmd  put –acl-public –guess-mime-type  –config=/var/www/html/.s3cfg   ".$file."  s3://".$bucket."  2>&1"$o);

echo implode("<br /> "$o);

?>

0 */12 * * * env php -q /var/www/html/s3bkup/s3bkup.php > /dev/null 2>&1 (per 12 hours)

You can set above php file as scheduled task (cronjob) for automated backup on Amazon S3 Bucket, I mostly use CloudBerry Explorer for Amazon S3 PRO for managing Amazon S3 files 😉

Installing XAMPP in Linux

What is XAMPP ?

XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. LAMPP (XAMPP for Linux) is very easy to install and to use – just download, extract and start.

Download XAMPP

http://sourceforge.net/projects/xampp/files/XAMPP Linux/

Installing XAMPP in Linux

Download XAMPP Latest version from the following link
http://sourceforge.net/projects/xampp/files/XAMPP Linux

Currently latest XAMPP version is 1.7.3a

$wget http://downloads.sourceforge.net/project/xampp/XAMPP%20Linux/1.7.3a/xampp-linux-1.7.3a.tar.gz?use_mirror=nchc

Now you should be having xampp-linux-1.7.3a.tar.gz in your downloaded location

Go to a Linux shell and login as root:
Perform these commands as root user

$ su -p
Extract the downloaded archive file to /opt

#tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt

XAMPP is now installed below the /opt/lampp directory.

Start XAMPP Server

To start XAMPP simply call this command:

#/opt/lampp/lampp start

Starting XAMPP for 1.7.3a…
XAMPP: Starting Apache with SSL (and PHP5)…
XAMPP: Starting MySQL…
XAMPP: Starting ProFTPD…
XAMPP for Linux started.

Test Your XAMPP Installation

OK, that was easy but how can you check that everything really works? Just type in the following URL at your favourite web browser:

http://localhost

Starting LAMPP automatically on startup
Starting LAMPP automatically on startup

XAMPP Security Configuration

As mentioned before, XAMPP is not meant for production use but only for developers in a development environment. The way XAMPP is configured is to be open as possible and allowing the developer anything he/she wants. For development environments this is great but in a production environment it could be fatal.

Here a list of missing security in XAMPP:

The MySQL administrator (root) has no password.
The MySQL daemon is accessible via network.
ProFTPD uses the password “lampp” for user “nobody”.
PhpMyAdmin is accessible via network.
Examples are accessible via network.
MySQL and Apache running under the same user (nobody).
To fix most of the security weaknesses simply call the following command:

#/opt/lampp/lampp security

It starts a small security check and makes your XAMPP installation more secure.
Start And Stop Server Services

start
Starts XAMPP.

stop
Stops XAMPP.

restart
Stops and starts XAMPP.

startapache
Starts only the Apache.

startssl
Starts the Apache SSL support. This command activates the SSL support permanently, e.g. if you restarts XAMPP in the future SSL will stay activated.

startmysql
Starts only the MySQL database.

startftp
Starts the ProFTPD server. Via FTP you can upload files for your web server (user “nobody”, password “lampp”). This command activates the ProFTPD permanently, e.g. if you restarts XAMPP in the future FTP will stay activated.

stopapache
Stops the Apache.

stopssl
Stops the Apache SSL support. This command deactivates the SSL support permanently, e.g. if you restarts XAMPP in the future SSL will stay deactivated.

stopmysql
Stops the MySQL database.

stopftp
Stops the ProFTPD server. This command deactivates the ProFTPD permanently, e.g. if you restarts XAMPP in the future FTP will stay deactivated.

security
Starts a small security check programm.

For example: To start Apache with SSL support simply type in the following command (as root):

#/opt/lampp/lampp startssl

You can also access your Apache server via SSL under https://localhost.

Important Configuration Files And Directories

/opt/lampp/bin/ – The XAMPP commands home. /opt/lampp/bin/mysql calls for example the MySQL monitor.
/opt/lampp/htdocs/ – The Apache DocumentRoot directory.
/opt/lampp/etc/httpd.conf – The Apache configuration file.
/opt/lampp/etc/my.cnf – The MySQL configuration file.
/opt/lampp/etc/php.ini – The PHP configuration file.
/opt/lampp/etc/proftpd.conf – The ProFTPD configuration file. (since 0.9.5)
/opt/lampp/phpmyadmin/config.inc.php – The phpMyAdmin configuration file.

Stopping XAMPP

To stop XAMPP simply call this command:

#/opt/lampp/lampp stop

You should now see:

Stopping XAMPP 1.7.3a…
XAMPP: Stopping Apache…
XAMPP: Stopping MySQL…
XAMPP: Stopping ProFTPD…
XAMPP stopped.

And XAMPP for Linux is stopped.

Starting LAMPP automatically on startup

For starting LAMPP automatically on startup, add the following line to you /etc/rc.local file

# /opt/lampp/lampp start

where /opt/lampp is the location where XAMPP files are kept. You will have to substitute the path to your XAMPP in the above command.

Uninstall XAMPP From your Machine

To uninstall XAMPP just type in this command

#rm -rf /opt/lampp


Install RED5 with java tomcat on linux

http://www.red5.org/
http://www.red5.org/

Red5 is an Open Source Flash Server written in Java that supports:

  • Streaming Audio/Video (FLV, h264, AAC, and MP3)
  • Recording Client Streams (FLV only)
  • Shared Objects
  • Live Stream Publishing
  • Remoting (AMF)

export variables in /etc/bashrc to become available for every user login or for any terminal opens.

echo “export ANT_HOME=/usr/local/ant” >> /etc/bashrc
echo “export JAVA_HOME=/usr/lib/jvm/java” >> /etc/bashrc

set CLASS PATH for java

# vi /etc/profile

JAVA_HOME=/usr/java/jdk1.6
export JAVA_HOME

Start/Stop Tomcat

# cd /usr/java/tomcat/bin
# ./shutdown.sh
# ./startup.sh

# cd ../webapps/
# netstat -ntlp|grep 1935

Install Tomcat

# wget http://www.trieuvan.com/apache/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.tar.gz
# tar xzf apache-tomcat-6.0.20.tar.gz
# ls
# mv apache-tomcat-6.0.20 tomcat
# mv tomcat /usr/java/
# cd /usr/java/tomcat/
# vi /etc/profile    (set class path)
# source /etc/profile
# /usr/java/tomcat/bin/startup.sh

Install Red 5

# wget http://dl.fancycode.com/red5/war/red5-0.6.2-java6.war
# ls
# cp red5-0.6.2-java6.war  /usr/java/tomcat/webapps/
# cd /usr/java/tomcat/bin
# ./shutdown.sh
# netstat -ntlp|grep 1935
# netstat -ntlp|grep 8080
# ./catalina.sh start

We are always hungry for TIME 😉


Lunarpages.com Web Hosting

Crontab Command Line

crontab Crontab Command Line

1. dump the content of the existing crontab to a file
# crontab > /tmp/dump
2. echo “your lines” >> to the corntab file
# echo ” 00 1 * * * /monitor_file_system 2>/dev/null” >> /tmp/dump
3. import the new crontab
# crontab /tmp/dump

other option….
# crontab -e
It will open a editor, add job here like
00 1 * * * /monitor_file_system 2>/dev/null

Set cronjob from other server:
# crontab -e
0 0 * * * curl http://www.domain.com/svnlabs.php

here svnlabs.php file is located on different server…

and save this crontab files…. now cronjob successfully installed 🙂