New Technologies

  • Java
  • Javascript
  • DTML
  • Dot Net
  • ASP .Net
  • C# .Net
  • PHP
Your Ad Here

Thursday, August 13, 2009

How to Build a Profitable Twitter Profile

Twitter is one of the fastest growing marketplaces on the Internet. The reason why so many people like Twitter is because it is actually the perfect communication tool for people who don't understand and don't want to learn about Internet technology and the technological geek-speak that goes along with it.

A few years back, I asked someone for his dad's email address. The son replied telling me that you just email his name. The son was clueless that there was an actual email address behind the shortcut for his dad's name. He did not understand email, and he did not care that he did not understand it. He was able to use it in a manner that was easy for him, and that is all that really mattered.

What makes Twitter so popular to the masses is that one does not have to be tech-savvy to use the service. The new user simply needs to locate the profile of the person he or she wants to follow, and then the user simply clicks "Follow". From that day forward, anytime the person "Followed" posts (tweets) new information to his or her micro-blog, Followers will be notified about the message in the Twitter Timeline.

 

The only thing that is really difficult about Twitter is that new people seldom understand that they must "Follow" someone, before they start to receive messages from others. But once someone has chosen to follow a few people, they get the idea behind Twitter very quickly.

With its' system of 140 character micro-posts (referred to as "tweets"), users are able to communicate information to other users. Sometimes the tweeted info is a random comment, but often the tweets mean something to somebody.

For the average consumer, they can log into Twitter to update grandma about the lives of the grandchildren and to provide links to family pictures.

Although the service has been available since 2006, the Internet marketing community was really slow to catch on to the value of the Twitter community. Most Internet marketers hadn't heard of Twitter until 2008. Even then, online marketers were slow to see any real value in the platform. But in 2009, Twitter finally hit its stride in getting the word out about its service, in large part due to the Ashton Kutcher vs. CNN Twitter Follower Challenge.

Ashton Kutcher (@aplusk) challenged CNN (@cnnbrk) to a race to one million Twitter Followers. On April 17th, 2009, Ashton became the first Twitter user to reach one million followers. CNN passed the mark a few hours later, but Ashton won the race fair and square.

Uploading Files with a Multipart POST

Uploading Files with a Multipart POST

11.9.1. Problem

You need to upload a file or a set of files with an HTTP multipart POST.

11.9.2. Solution

Create a MultipartPostMethod and add File objects as parameters using addParameter( ) and addPart( ). The MultipartPostMethod creates a request with a Content-Type header of multipart/form-data, and each part is separated by a boundary. The following example sends two files in an HTTP multipart POST:

               import org.apache.commons.httpclient.HttpClient;

import org.apache.commons.httpclient.HttpException;

import org.apache.commons.httpclient.methods.MultipartPostMethod;

import org.apache.commons.httpclient.methods.multipart.FilePart;

HttpClient client = new HttpClient( );

       

// Create POST method

String weblintURL = "http://ats.nist.gov/cgi-bin/cgi.tcl/echo.cgi";

MultipartPostMethod method =

    new MultipartPostMethod( weblintURL );

File file = new File( "data", "test.txt" );

               File file2 = new File( "data", "sample.txt" );

               method.addParameter("test.txt", file );

               method.addPart( new FilePart( "sample.txt", file2, "text/plain",

"ISO-8859-1" ) );

// Execute and print response

client.executeMethod( method );

String response = method.getResponseBodyAsString( );

System.out.println( response );

method.releaseConnection( );

Two File objects are added to the MultipartPostMethod using two different methods. The first method, addParameter( ), adds a File object and sets the file name to test.txt. The second method, addPart(), adds a FilePart object to the MultipartPostMethod. Both files are sent in the request separated by a part boundary, and the script echoes the location and type of both files on the server:

<h3>Form input</h3>

<pre>

sample.txt = /tmp/CGI14480.4 sample.txt {text/plain; charset=ISO-8859-1}

test.txt = /tmp/CGI14480.2 test.txt {application/octet-stream;

charset=ISO-8859-1}

</pre>

11.9.3. Discussion

Adding a part as a FilePart object allows you to specify the Multipurpose Internet Main Extensions (MIME) type and the character set of the part. In this example, the sample.txt file is added with a text/plain MIME type and an ISO-8859-1 character set. If a File is added to the method using addParameter( ) or setParameter( ), it is sent with the default application/octet-stream type and the default ISO-8859-1 character set.

When HttpClient executes the MultipartPostMethod created in the previous example, the following request is sent to the server. The Content-Type header is multipart/form-data, and an arbitrary boundary is created to delineate multiple parts being sent in the request:

POST /cgi-bin/cgi.tcl/echo.cgi HTTP/1.1

User-Agent: Jakarta Commons-HttpClient/3.0final

Host: ats.nist.gov

Content-Length: 498

Content-Type: multipart/form-data; boundary=----------------31415926535

8979323846

------------------314159265358979323846

Content-Disposition: form-data; name=test.txt; filename=test.txt

Content-Type: application/octet-stream; charset=ISO-8859-1

Content-Transfer-Encoding: binary

This is a test.

------------------314159265358979323846

Content-Disposition: form-data; name=sample.txt; filename=sample.txt

Content-Type: text/plain; charset=ISO-8859-1

Content-Transfer-Encoding: binary

This is a sample

------------------314159265358979323846--

Each part contains a Content-Disposition header to name the part and a Content-Type header to classify the part with a MIME type and character set.

 

Monday, August 3, 2009

Online subscription to RSS feeds using Google Reader.

we can subscribe and manage to RSS feeds using Google feature Google Reader.
In this the trends is very useful feature.
and we can categorise and share with other friends.
http://www.google.com/reader
Post images in Tweeter

How do I create a Twitpic account?
If you have a Twitter account then you already have a Twitpic account, just login to Twitpic with your Twitter username and password and you are all set.

If you don't have a Twitter account you can sign up for one for free at Twitter.com
How do I delete a photo?
1. Login to Twitpic
2. Click the "Home" link at the top of the page, this will take you to your photo stream
3. Click the trash can icon () next to the photo you wish to delete
How do I delete a comment on my photo?
1. Login to Twitpic
2. Navigate to the photo with the comment you wish to delete
3. Click the trash can icon () next to the comment you wish to delete
How do I delete a tag on my photo?
1. Login to Twitpic
2. Navigate to the photo with the tag you wish to delete
3. Click the trash can icon () next to the tag you wish to delete

http://www.twitpic.com/faq.do

Sunday, June 21, 2009

MySQL Crash Recovery

MySQL Crash Recovery
MySQL is known for its stability but as any other application it has bugs so it may crash sometime. Also operation system may be flawed, hardware has problems or simply power can go down which all mean similar things – MySQL Shutdown is unexpected and there could be various inconsistences. And this is not only problem as we’ll see.
MySQL has angel process mysqld_safe which will restart MySQL Server in most cases. It is great, unless you have run into some bug which causes it to crash again – such crashes qucikly following one another are kind of worse because they explore many less tested code paths in MySQL and so problem potential is larger.
So lets look at the problem which happen during the crash which might need to take care of or which may seriously affect MySQL Performance.
MyISAM Corruption - If you’re writing to MyISAM tables there is very large chance of them becoming corrupted during the crash. Note corruption may be hidden and do not expose itself instantly – you may notice wrong query results days after crash. Sometimes corrupted tables may be reason for further crashes or hangs, and corruption may spread itself further in the table. You probably do not want any of these so it is very good idea to run MySQL with myisam_recover option which will make sure all improperly closed MyISAM tables are checked first time it is accessed. This option is however rather painful to use with web applications – users may issue different queries which may trigger check/repair running for many tables at onces, which typically make system extremely slow and also can use up all allowed connections or run out of memory ( myisam_sort_buffer_size is normally set pretty lage). If this becomes the problem I use tiny script which moves out all MyISAM tables out of MySQL database directory, checks them with MyISAMchk and moves them back to running server. This looks scary but it works great – until table is checked and ready application gets error rather than stalling forever which allows application to become partially functional as soon as possible. This hack is needed only in some cases – in most cases using Innodb for tables which you need to be recovered fast is better solution.
Innodb Recovery – Unless you have some hardware problems (99%) or found new Innodb bug (1%) Innodb recovery should be automatic and bring your database to consistent state. Depending on innodb_flush_lot_at_trx_commit setting you may lose few last committed transactions but it is it. It is Performance of this process which may cause the problems. As I already wrote innodb_log_file_size and innodb_buffer_pool_size affect recovery time significantly as well as your workload. I should also mention if you have innodb_file_per_table=1 your recovery speed will depend on number of Innodb tables you have, as well as many other operations, so beware.
Binary log corruption - Binary log may become corrupted and out of sync with database content. This will sometimes break replication but if you’re just planning on using binary log for point in time recovery it can go unnoticed. sync_binlog Is helping by syncing binary log, but at performance penalty. If using Innodb you also might with to use innodb-safe-binlog option in MySQL 4.1 so your Innodb log and binary log are synchronized. In MySQL 5.0 XA is taking care of this synchronization.
.frm Corruption – Few people know MySQL is not really ACID even with Innodb tables, at least not for DDL statements.
There is a chance of failing for example during CREATE statement with table created in Innodb dictionary but .frm not created or not completely written. Partially written .frm files or .frm being unsync with internal Innodb dictionary may cause MySQL to fail with wierd error messages. In MySQL 4.1 sync_frm option was added which reduces this problem as time window when it can happen is much less. Still if failure happens just during writting .frm file nasty things may happen, not to mention such potentially multiple operation DDL statements as RENAME TABLE – these are most vulnerable.
master.info corruption - If slave happens to crash you can also have relay logs corruption and master.info being corrupted. Not to mention MyISAM tables can contain partially completed statements as well as some of updates totally lost. The safe approach it to reclone the slaves if they crash or you can take the risks and try to continue. Sometimes you might be able to manually find appropriate position even if master.info file is out of sync but I would not be basing my failure handling scenarios.
Cold Start – If you restart MySQL server its caches (key_buffer, innodb_buffer_pool, query_cache,table_cache) are cleaned, so may be OS caches. This may reduce performance dramatically. So if you’re bringing server back after crash you might want to populate caches. For MyISAM key_cache this can be done by using LOAD INDEX INTO CACHE statement, for other storage engines it can be done by issuing large index scan queries. Full table scan queries allow to preload table data ether in storage engine caches or in OS cache. You can save these into .sql file and use –init-file to make sure it is run on startup. The other approach is to prime server with real servers (ie clone queries from other slave) before putting traffic to it.
In case application is not highly available so there is only one server you might with to start serving only some users initially (returning error to others) and gradually increase the load as server warms up. This may sound strange but makes a lot of sense as not only waiting for pages which never load is more frustrating for users than getting honest “try again later” message, but also – warmup takes longer time on extreme load.
Innodb statistics - Unlike MyISAM Innodb does not store index cardinality in tables, instead it computes them on first table access after startup. This may take significant time if you have very large number of tables (Some users have hundreds of thousands of tables per database host). This one is pretty much part of cold start problems but I wanted to point out it separately. To warmup this data you might run select 1 from _table_ limit 1 for each table or any other statement – it is table open which is important.
There are other problems which you may experience related to MySQL Crash Recovery – Restoring data from backup, corrupted Innodb tablespace recovery etc but I should write about them some other time.

Reference by : http://www.mysqlperformanceblog.com/2006/07/30/mysql-crash-recovery/

 

Understanding MySQL Query Cache for PHP Developers

Problem Statement:

Many PHP developers using MySQL have unclear understanding of the MySQL query cache. So we decided to write a series of introductory articles to get everyone on the same page. This article is the first installment of the series and here we will introduce the basics of query cache in MySQL. Note that unlike a typical book chapter, this article will be of low-fat flavor — less theory and more actionables — of an introduction to query caching for MySQL.

What is a MySQL query cache?

It turns out that MySQL has a built-in query cache that can cache a specific type of queries — SELECT statements — to speed up delivery of the result sets. The cache can increase performance for many instances but can also hurt performance if not used wisely.

What can be cached in the MySQL query cache?

Only SELECT statements can be cached. This does not include prepared SELECT statements. Query caching only works for SELECT statements that are fully qualified and returns same result every time. This means you cannot use non deterministic functions that return data depending on situation. For example:

// Following SELECT query can be cached

$stmt = "SELECT * FROM user WHERE active = 1";

 

// Following SELECT query cannot be cached

$stmt = "SELECT * FROM user where signup_date >= NOW()";

 

// Following SELECT query cannot be cached

$stmt = "SELECT count(*) FROM user";

Here are the requirements a query must meet to take advantage of the query cache:

  • Only exact queries are serviced from the cache — must match the stored query in exact detail.
  • Queries with placeholders — such as the ones for prepared statements — are not cached in query cache
  • Queries with user defined functions or non-deterministic functions cannot be cached
  • Any table changes (such as issuing of an ALTER statement) will remove the queries from the cache for that table

Introduction to query cache parameters

The more you understand the query caching parameters, the better you are going to be at tuning the query cache to your advantage. First find out what are the global query caching parameters that you can fiddle with using the following query at the mysql command-line prompt.

mysql> show global  variables like '%query_cache%';

A sample output is shown below:

+------------------------------+-----------+

| Variable_name                | Value     |

+------------------------------+-----------+

| have_query_cache             | YES       |

| query_cache_limit            | 1048576   |

| query_cache_min_res_unit     | 4096      |

| query_cache_size             | 536870912 |

| query_cache_type             | ON        |

| query_cache_wlock_invalidate | OFF       |

+------------------------------+-----------+

6 rows in set (0.00 sec)

The purpose of these parameters are described briefly as:

  • have_query_cache - size of query cache in bytes
  • query_cache_limit - the maximum size of result set (default: 1048576 bytes or 1 MB). If your query returns result set that is greater than the limit set here, it will NOT BE CACHED
  • query_cache_min_res_unit - the smallest block size allocated by query cache. Default is 4KB
  • query_cache_size - the total memory available to query cache
  • query_cache_type - when set to ON or 1, query caching is on for all applicable queries, when set to OFF (0) query caching is turned off and when set to DEMAND or 2, caching is on for queries with SQL_CACHE directive in the query
  • query_cache_wlock_invalidate-causes the query cache to invalidate any query in the cache if a write lock is executed against the table(s) it uses

Whats your query cache status right now?

To find out whats going on with your query cache, run the following command from the MySQL command-line prompt:

mysql> show status like '%qc%';

Here is a sample result:

+-------------------------+-----------+

| Variable_name           | Value     |

+-------------------------+-----------+

| Qcache_free_blocks      | 978       |

| Qcache_free_memory      | 527371984 |

| Qcache_hits             | 645545    |

| Qcache_inserts          | 130796    |

| Qcache_lowmem_prunes    | 0         |

| Qcache_not_cached       | 417579    |

| Qcache_queries_in_cache | 4973      |

| Qcache_total_blocks     | 11167     |

+-------------------------+-----------+

8 rows in set (0.00 sec)

Here are some brief explanations of these status metrics:

  • Qcache_free_blocks - number of memory blocks marked as free, which indicates memory fragmentation
  • Qcache_free_memory - total amount of memory free for query cache
  • Qcache_hits - number of times query result was found in the query cache
  • Qcache_inserts - number of times queries were written to the query cache
  • Qcache_not_cached - number of queries removed from cache due to low cache memory
  • Qcache_queries_in_cache - number of queries that could not be cached
  • Qcache_total_block - total number of blocsk in query cache

Calculating query cache hits vs misses

Here is the formula for calculating hit ratio for query cache:

$totalSelectQueryCount = $comSelect + $qcacheHits

$percentHits           = ($qcacheHits * 100)/ $totalSelectQueryCount

What the above formula does is adds up all the SELECT queries in the system using two MySQL global variables: com_select and qcache_hits.

To set $comSelect, run show global status like '%com_select%' query. For example:

mysql> show global status like '%com_select%';

+---------------+---------+

| Variable_name | Value   |

+---------------+---------+

| Com_select    | 1739663 |

+---------------+---------+

To set $qcacheHits, run show status like '%qcache_hit%'. For example:

mysql> show  status like '%qcache_hit%';

+---------------+----------+

| Variable_name | Value    |

+---------------+----------+

| Qcache_hits   | 20786961 |

+---------------+----------+

With the above sample number, the percent hit is 92.28% which is great.

Managing query cache

To manipulate your query cache, you can use the following MySQL statements from the MySQL command-line:

To remove all the queries from your query cache, run:

RESET QUERY CACHE;

To defragment the query cache memory, run:

FLUSH QUERY CACHE;

 

Tuesday, June 16, 2009

8 Popular Open Source Forums

The list below is a collection of 8 popular Open Source Forum software.

·       - phpBB is one of the most popular forum softwares. With phpBB you can customize with mods and you can stylize your forum. For a fully Modded phpBB forum with about 500 different mods that all have been fully tested click here.

·       - Vanilla is a lightweight open source forum that was developed by Mark O’Sullivan using PHP and MySQL. Vanilla comes loaded with extensions, and you can customize the forum with your own add-ons.

·       - YetAnotherForum.NET is a Open Source forum or bulletin board for web sites running ASP.NET. YetAnotherForum.NET is fully coded in C# ASP.Net and uses Microsoft SQL Server. It comes with all the standard forum features and even WYSIWYG editors.

·       - YaBB is an Open Source forum system (bulletin board, message board) written in Perl. This system is the first and most popular open-source perl forum software and it runs very fast.

·       - IceBB is an open-source forum solution powered by PHP and MySQL. IceBB is written with the prototype and scriptaculous frameworks and the code output is very clean. IceBB has mostly all the same features as some of the paid forums but it even has an RSS feed.

·       - WP-Forum is a simple discussion forum plugin for WordPress. It has three themes that you can choose from and is a simple solution if you have a WordPress powered site.

·       - miniBB is an open source message board script written in PHP. miniBB is a lightweight and compact alternative to phpBB. With miniBB you can customize the software with add-ons and it is Search Engine Optimized.

·       - SMF is a free professional grade forum software that actually isn’t open source. SMF has loads of features with a great community and tons of free modifications.

If you know of any more Open Source Forums then please comment below. Thanks!!!

Popularity: 100%

Your Ad Here