Knowledge Base

February 22, 2008

mysql_pconnect() vs mysql_connect()

Filed under: Technical — Tags: , , — rkutti @ 12:35 pm

When connecting, the pconnect wolud first try to find a (persistent) link that’s already open with the same host, username and password. If the link already exist then the identifier for that will be returned instead of opening a new connection. Later, create a new link for each connection.

The Connection to the SQL server will not be closed when the execution of the script ends. Instead the link will be opened for future use and mysql_close() will not will not close links established by mysql_pconnect(). Later, The link to the server will be closed as soon as the execution of the script ends, unless its closed earlier by explicitly calling mysql_close().

Reference: mysql_pconnect() and mysql_connect()

February 20, 2008

Take the dump of Postgresql database from Linux console

Filed under: Technical — Tags: , , , , — rkutti @ 12:28 pm

*To dump data or structure in the database from a dump file

$psql -u DBUserName datbaseName < databaseName_dump.sql

*To take the dump from the database

$pg_dump -u databaseName > filename.sql // data + structure
It will ask the username and password of database

$pg_dump -u databaseName -a > filename.sql // only data

$pg_dump -u databaseName -s > filename.sql // only structure

$pg_dump –username=sql-ledger -W databaseName > filename.sql
It will ask the password of database

February 6, 2008

Some usefull Linux Commands

Filed under: Technical — Tags: , — rkutti @ 9:59 am

To know the ip address of the machine
$ifconfig

To view list of previously typed commands in command prompt
$history | grep <word that need to be searched>

To Know the ip address of the website
$host site-name

To list all the process running in a machine
$ps aux

To kill a process that is running
$kill -9 the process code

To know which process consumes more space
$top

To know how much space the folder occupies
$du -sh .

January 31, 2008

Display textarea content with line breaks in html page

Filed under: Technical — Tags: , , , — rkutti @ 12:21 pm

Let us see how javascript, php, and ruby display the content of textarea with line breaks

Javascript:

document.getElemnetById(‘textareacontent’).value.replace(/\n/g,’<br>’);

PHP:

preg_replace(“/\n/”,”<br>”,$_REQUEST['t1']);

Ruby:

(teaxtareacontent).gsub(/\n/,”<br>”)

January 29, 2008

PHP Singleton Object

Filed under: Technical — Tags: , — rkutti @ 1:58 pm

The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.

Here is an example, that demonstrates this singleton pattern: (more…)

January 23, 2008

Take the dump of database from the console

Filed under: Technical — Tags: , , — rkutti @ 8:09 am

To take dump of whole database:
$ mysqldump -u <username> -p <databasename> > <filename>.sql

To take dump of the (only)structure of the database
$ mysqldump -u <username> -p <databasename> -d > <filename>.sql

To take dump of the (only)data of the database
$ mysqldump -u <username> -p <databasename> -t > <filename>.sql

To take dump of the database with complete insert statement
$ mysqldump -u <username> -p <databasename> -c > <filename>.sql

January 8, 2008

How to create database using mysql commands

Filed under: Technical — Tags: — rkutti @ 9:39 am

To create database from command prompt. Login to mysql as root user.
To login into mysql prompt in linux machine.
Type the following command in the console

$ mysql -u <username> -p<password>

After entering the mysql prompt follow these steps to create a database
and load the database with sql file.

A CREATE DATABASE statement to create a database.
> create database <databasename>;

A GRANT statement to grant privileges to database.
> grant all on <databasename>.* to <username>@localhost identified by ‘<password>’;

A FLUSH PRIVILEGES statement to tell the server to reload the grant.
> flush privileges;

A USE statement to tell the server to use the given database for further operations.
> use <databasename>;

A SOURCE statement to tell server to load the given sql file in the database.
> source <filename.sql>

December 10, 2007

Microformats

Filed under: Technical — Tags: , — rkutti @ 4:29 am

Microformats are tiny little markup definitions built on top of, usually, HTML or XHTML.

The available microformats are hCalendar, hReview, hCard, RelLicense, RelTag, XFN Format etc.,

The basic format of hCard is to use vCard object/property names in lower-case for class names, and to map the nesting of vCard objects directly into nested XHTML elements.

For example, Here is a sample vCard

BEGIN:VCARD
VERSION:3.0
FN:Jeffrey Thomas
END:VCARD

and an equivalent in literal hCard:
< p class=”vcard”> < span class=”fn”>Jeffrey Thomas < \span > < \ p>

There are several ruby parser for parsing this microformats to mention a few like mofo, hpricot etc

Check the microformats wiki for further details.

Importance of Microformats

Helps in – Aggregation Sites and Sharing Information with a Specific Community

You can also get more information from this blog about microformats and how websites using this.

October 18, 2007

Using Hpricot to fetch the title of the url passed

Filed under: Technical — rkutti @ 9:47 am

When surfing the net I found Hpricot for Ruby.This helps me in parsing the HTML pages.
To install ‘hpricot’ use gem installer..
In the command prompt type this to install ‘hpricot’
gem install hpricot

Then in your code include ‘hpricot’ using

require ‘hpricot’
require ‘open-uri’

@title = (Hpricot(open(url))/:title).inner_text

This code will help in fetching the title of the html pages.

The code under my prevoius post ‘Get the title of the given url using ruby’ can be replaced with this code. This reduces the number of lines of code.

I got this code from this link
The usage of Hpricot doesn’t stop with this. It is used in many cases, i will post usages of ‘hrpicot’ in future.

October 8, 2007

BumpedINTO.com

Filed under: Technical — rkutti @ 7:46 am

BumpedInto is a Social Profile Bookmarking application which helps you in achieving your goals.

You can take a quick look of the tour to know more about this bookmarking application.

Tour

Click here to Sign-Up

Older Posts »

Blog at WordPress.com.