Archive

Posts Tagged ‘how’

log4j appenders – power of logging

April 28th, 2011 228 views No comments

Better replacement of System.out.println() is using log4j with console appender (You must have seen its example in How to use Log4j – An efficient and sufficient guide with examples).

ConsoleAppender might be useful for small applications or when you want to track application flow live. But if want to know historical flow/fault of your system you need to write logs to a file. As per need, log4j provides different set of appenders.

ConsoleAppender Logs to console
FileAppender Logs to a file
SMTPAppender Logs by email

*You would have to set file name for FileAppender.

Sample log4j.properties

log4j.rootLogger=DEBUG, CA, FA, mail

#Console Appender
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

#File Appender
log4j.appender.FA=org.apache.log4j.FileAppender
log4j.appender.FA.File=sample.log
log4j.appender.FA.layout=org.apache.log4j.PatternLayout
log4j.appender.FA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

# Set the logger level of File Appender to WARN
log4j.appender.FA.Threshold = WARN

Description
CA appender will show all logs on console for all levels ie debug, warn, error, fatal and info. While FA appender will write logs to sample.log file for warn, error and fatal levels. Last line of above property file, will set logger level for FA appender.

Each Appender object has different properties associated with it

Property Description
layout Appender uses the Layout objects and the conversion pattern associated with them to format the logging information.
target The target may be a console, a file, or another item depending on the appender. For example;

System.out in case of ConsoleAppender

Sample.log in case of FileAppender

I hadn’t tried file name or file stream in case of ConsoleAppender

level The level is required to control the filteration of the log messages.
threshold Appender can have a threshold level associated with it independent of the logger level. The Appender ignores any logging messages that have a level lower than the threshold level.
filter The Filter objects can analyze logging information beyond level matching and decide whether logging requests should be handled by a particular Appender or ignored.

*Every appender has some more properties inside.

Reference

WordPress Multi Select Category Box

April 8th, 2011 795 views 4 comments

While developing some pages of my new site thinkzarahatke, I faced problem to display a multiple select category box. WordPress provides wp_dropdown_categories() function which display you a combo(select) box of categories. You can select only one category at a time.

Since I dint found any other function which can help me and I was not willing to use any plug in for the same so I set multiple attribute to select box at run time using jquery.

$(function() {
           $(".multiselect").attr( 'multiple', 'multiple' );
});

Using the above code you can make multi select category box easily.

Really Simplest CAPTCHA integration

March 13th, 2011 172 views No comments

CATCHA is required for humanity check. So you can save your site from any script attack. If you are running a site on wordpress platform then implementing CAPTCHA would be so much easier. The same script you can use to integrate in any PHP site.

1

Write a function to display CAPTCHA somewhere on your site.

function Display_captcha(){
	$common_captcha = new ReallySimpleCaptcha();
	$common_captcha_defaults = array(
			'chars' => 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789',
			'char_length' => '4',
			'img_size' => array( '72', '24' ),
			'fg' => array( '0', '0', '0' ),
			'bg' => array( '255', '255', '255' ),
			'font_size' => '16',
			'font_char_width' => '15',
			'img_type' => 'png',
			'base' => array( '6', '18'),
			);

	/**************************************
	* All configurable options are below  *
	***************************************/

	// Set Really Simple CAPTCHA Options
	$common_captcha->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789amty';
	$common_captcha->char_length = '4';
	$common_captcha->img_size = array( '72', '24' );
	$common_captcha->fg = array( '0', '0', '0' );
	$common_captcha->bg = array( '255', '255', '255' );
	$common_captcha->font_size = '16';
	$common_captcha->font_char_width = '15';
	$common_captcha->img_type = 'png';
	$common_captcha->base = array( '6', '18' );

	// Set common Form Options

	// Generate random word and image prefix
	$common_captcha_word = $common_captcha->generate_random_word();
	$common_captcha_prefix = mt_rand();
	// Generate CAPTCHA image
	$common_captcha_image_name = $common_captcha->generate_image($common_captcha_prefix, $common_captcha_word);
	// Define values for common form CAPTCHA fields
	$common_captcha_image_url =  get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/';
	$common_captcha_image_src = $common_captcha_image_url . $common_captcha_image_name;
	$common_captcha_image_width = $common_captcha->img_size[0];
	$common_captcha_image_height = $common_captcha->img_size[1];
	$common_captcha_field_size = $common_captcha->char_length;
	// Output the common form CAPTCHA fields
	$common_captcha_arr = array(
		array ( 'img',$common_captcha_image_src,$common_captcha_image_width, $common_captcha_image_height),
		array ( 'text',$common_captcha_field_size),
		array ( 'hidden',$common_captcha_prefix),

	);
	return $common_captcha_arr;
}

2

Write a function to verify CAPTCHA.

function Verify_captcha($prefix,$code)
{
	$question_captcha = new ReallySimpleCaptcha();
		$question_captcha_prefix = $prefix;
		$question_captcha_code = $code;
		$question_captcha_correct = false;
		$question_captcha_check = $question_captcha->check( $question_captcha_prefix, $question_captcha_code );
		$question_captcha_correct = $question_captcha_check;
		$question_captcha->remove($question_captcha_prefix);
		$question_captcha->cleanup();
		if ( ! $question_captcha_correct ) {
			return false;
		}
		return true;
}

3

Display it somewhere on your form.

< form
< ?php $common_captcha_arr = Display_captcha(); ?>
< p class="common-form-captcha">
< img src="<?php echo $common_captcha_arr[0][1]; ?>" alt="captcha" width="<?php echo $common_captcha_arr[0][2]; ?>" height="<?php echo $common_captcha_arr[0][3]; ?>" />
< input id="common_captcha_code" name="common_captcha_code" size="<?php echo $common_captcha_arr[1][1]; ?>" type="text" class="textfield2" />
< input id="common_captcha_prefix" name="common_captcha_prefix" type="hidden" value="<?php echo $common_captcha_arr[2][1]; ?>" />
< /p>
< /form>

4

Verify it.

if(! Verify_captcha($_POST['common_captcha_prefix'],$_POST['common_captcha_code'])){
  :
}

* You would have to download & Install really-simple-captcha

Simplest Shortest Sweetest Servlet tutorial – Part 1b including Tomcat configuration

February 13th, 2011 177 views No comments

Development and deployment of J2EE applications are different than java standalone applications.

Simplest Shortest Sweetest Servlet tutorial – Part 1 will tell you about basic concept of servlet. And will remove your fear to build any J2EE application

Sample Java Servlet for your reference has sample code for your reference purpose.

But now you need to know practically how to develop a servlet based J2EE application. Although it is possible to develop all the code with only JDK but I’ll suggest to use some IDE like Eclipse or NetBeans.

Watch below shortest servlet video tutorial….(Eclipse)

Servlet development using Eclipse and Tomcat


If you want to switch from Eclipse to Netbeans or vice versa refer below articles;
How to import NetBeans project into Eclipse

How to import NetBeans project into Eclipse

February 12th, 2011 9741 views 2 comments
netbeans Few days ago, when I faced some issues with NetBeans IDE, I switched to Eclips. Now the problem was my work. Placing java files from one place to another seems easy. But preparing configuration file is really time-consuming. And as usual I avoid manual work. SO let’s see what I did to import NetBeans workspace into Eclipse without wasting time
1


  1. There is a dist folder inside NetBeans workspace, containing a .war file. Import this war file into Eclipse. For this;
    1. Open eclips IDE > Go to File Menu => Import => War
  2. Above step will make package structure in Eclipse workspace similar to NetBeans. It’ll also prepare configuration file. Now you need to place source files only. For this
    1. Go to src folder inside NetBeans folder => Copy all contents => Place them to src folder inside NetBeans folder.
    2. Right click on Project name in right side panel of Eclipse IDE => Refresh

Your Eclipse workspace is prepared. If above trick doesn’t work for you refer another way;

2


OVERVIEW OF THE PROCESS

  1. Lets say you already have a NetBeans project created called MyProject and located at <PATH>\MyProject
  2. open NetBeans and change the project settings
  3. create a ZIP file of the <PATH>\MyProject\MyProject.zip
  4. create a new folder <PATH>\NEW (or your choice), this is where we are going to create the Eclipse Project
  5. open Eclipse create a new project and import the ZIP file
  6. create a new folder <PATH>\NEW\MyProject\dist(necessary for NetBeans)
  7. Now you can DECIDE when to work with Eclipse or NetBeans

DETAILED PROCESS

  1. Let’s say you already have a NetBeans project created called MyProject and located at <PATH>\MyProject
  2. open NetBeans
    • open MyProject
    • Right click MyProject and select Clean Project (this deletes the build/classed and dist folders)
    • open the file project.properties located in the folder <PATH>\MyProject\nbproject
    • change the build.dir to bin
    • change the build.classed.dir to ${build.dir}
    • save and close the file

close NetBeans

  1. create a ZIP file of the <PATH>\MyProject\MyProject.zip that will contain this folders:
    • nbproject
    • src
    • Any other folder or file that is located at <PATH>\MyProject
  2. create a new folder <PATH>\NEW (or your choice), this is where we are going to create the Eclipse Project
  3. open Eclipse
    • go to Window, Open Perspective, Java
    • go to File, New, Project, Java Project
    • click NEXT
    • type MyProject
    • select Create project at external location
    • type <PATH>\NEW\MyProject (this folder will be created by ECLIPSE)
    • select Create separate source and output folders
    • click NEXT
    • click FINISH
    • Right click on MyProject (at the Package Explorer)
    • select IMPORT
    • select ZIP file (usually the last option on the list)
    • click NEXT
    • BROWSE and look for the <PATH>\MyProject\MyProject.zip created on STEP 3
    • click FINISH

close Eclipse

  1. create a new folder <PATH>\NEW\MyProject\dist(necessary for NetBeans)
  2. Now you can DECIDE when to work with Eclipse or NetBeans

How to stop a user to upload big size files?

February 9th, 2011 589 views 3 comments

If you are planning to validate a file over its size at client side only using some java script then SORRY.
File upload

Listen

Listen

Listen

You need not to be disappointed. I have many solutions

  1. ActiveX control
    Write the following code in script tag in your HTML.

    function getSize()
    {
    	var myFSO = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;);
    	var filepath = document.upload.file.value;
    	var thefile = myFSO.getFile(filepath);
    	var size = thefile.size;
    	alert(size + &quot; bytes&quot;);
    }
    

    Please note this
    Use of ActiveX control is always avoided due to security reasons.
  2. Java Applet – I had written a Java applet. But i’ll prefer to write a separate code for the same.
  3. SWF – I haven’t tried it before. But it is a very good option.
  4. .htaccess
    Write following line in your .htaccess file.

    LimitRequestBody 2097152

    Apache error log will generate this entry when you exceed this limit on a form post or get request:

    Requested content-length of 4000107 is larger than the configured limit of 2097152
    

    And it will also display this message back in the web browser:

    &lt;h1&gt;Request Entity Too Large&lt;/h1&gt;

    By the way, the error number returned is 413. So, you could use a directive in your .htaccess file.

    Redirect 413 413.html
  5. Best way:
  6. Let client upload the file. Don’t write it at server end immediately. Instead,

    1. Create a file progress bar who monitors how much part of a file has been uploaded.
    2. Once it crosses maximum specified size limit;
      1. Leave writing
      2. Prompt the client.

    Now see how to implement this logic in Java

    1

    Download following jars

    • commons-fileupload-1.2.1
    • commons-io-1.4

    You will get them easily on apache sites.


    2

    Add following code in your java class say servlet.

    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.*;
    
    import org.apache.commons.io.*;


    3

    Following line will help you to identify whether client is uploaded a file or not.

    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    


    4

    If yes then first read all the values through some iterator. And check whether there is any non form field (means whether the current item is a file)

    Object img = itr.next();
    FileItem item = (FileItem) img;
    if (!item.isFormField()){
    :
    }
    


    5

    Now its up to you whether you write a file on your server immediately. Or Byte by Byte. I’ll suggest for second option.

    byte[] boundary = &quot;article-stack.net&quot;.getBytes();
    //byte[] boundary = new byte[1000000]; //geting hanged by defining fixed no of bytes
    try{
        MultipartStream ms = new MultipartStream(item.getInputStream(),boundary,1000);
    
        FileOutputStream fileOut = new FileOutputStream(savedFile);
        ms.readBodyData(fileOut);
        fileOut.flush();
        fileOut.close();
    }catch(Exception exp)
    {
      savedFile.delete();
      exp.printStackTrace();
    }
    


    6

    Its not done boss. You have to write a progress listener.

    ProgressListener progressListener = new ProgressListener(){
       private long megaBytes = -1;
       public void update(long pBytesRead, long pContentLength, int pItems) {
           long mBytes = pBytesRead / 1000000;
           if (megaBytes == mBytes) {
               return;
           }
           megaBytes = mBytes;
           System.out.println(&quot;We are currently reading item &quot; + pItems);
           if (pContentLength == -1) {
               System.out.println(&quot;So far, &quot; + pBytesRead + &quot; bytes have been read.&quot;);
           } else {
               System.out.println(&quot;So far, &quot; + pBytesRead + &quot; of &quot; + pContentLength
                                  + &quot; bytes have been read.&quot;);
           }
       }
    };
    

    Modify the above progress listener as per your need to limit the file size.

Happy……..

How to calculate the minimum payment on credit card?

January 20th, 2011 308 views No comments

I never prefer to read articles having heavy terms and their explanation. :-( Since credit cards are common among all. So this information is available for people in interest of keeping knowledge about credit card payment. :-)

I’ll update you soon with some interactive ways for credit card selection.

Minimum payment

Minimum payment is a required by the bank sum, that is determinate by percentage of the borrowed amounts from balance of the credit card and stands at usually 2-5%. As standard do banks require between 2 to 5% of the outstanding balance to be paid on the monthly basis along with interest or it can also be a fixed amount of dollar for a low balance, which as standard is $15.00 for US and Canada and about £5.00 on most credit cards in UK, usually depends on whichever is greater.

Ways of calculating a minimum payment is pretty simple is to multiply the balance on the minimum percentage (2-5%) required paying, which is greater than the sum of interest to cover partial principal payment. The calculator above has an option to define a minimum only or a minimum plus interest ways to pay.

credit card
Fixed Payments on Low Balance

Fixed Payments on Low Balance is paid when the minimum payment, which usually between 2 and 5% of the balance are lower than that fixed payment amount, which is $15.00 for US and Canada or £5.00 for UK on most Credit Cards. In other words the minimum amount required to be paid towards principal is between 2 to 5% of the balance of the credit card. The fixed amount will be paid only when the minimum amount, calculated as percentage of the balance will become equal to or lower than that fixed payment amount.

Principal Payment Distribution.

This is defined as distribution of the principal payment on two lines of credit described as balance on purchases and cash balance of the credit card. Because of the difference in interests for this balances, most banks usually leave cash balance payments right until the very end of clearance of the balance on purchases or may only allocate a very little portion of principal towards those cash balance repayments. You can change this by changing the value of the cell named “Principal Payment Distribution” by changing the percentage of allocation that it usually varies between 0% and 15% depending on your credit cards agreement.

Fixed amount and Additional Payment.

Fixed amount can be any amount that has been decided to pay, but it must be equal or above than the first month payment amount. Making fixed monthly payments will make a significant difference on the number of payments and total interest paid, this will let you pay your credit card balance much sooner and for sure save some interest too. Do not get confused by definition of a Fixed Payment and Fixed Payment on low balance, since this two are completely different payments.

Additional payments are usually the payments that are made occasionally. Depending on the sums paid this can also be a big difference to the paid interest amounts as well as reduction of the number of payments. Both methods can be used with our calculator.

Payment Protection Insurance Payments.

Payment Protection Insurance, also known as PPI is a product that is being sold to you by your bank when you take a loan or credit card. Depending on the agreement PPI will either be deducted from your credit card balance or can be added to your monthly payment. There is a big difference in between, if your PPI premium is deducted from your credit card balance, which is as usual considered as a standard purchase with your credit card as if you were shopping with it, which means that you will also be charged an interest for this and if you are making only a minimum payments you will not be able to cover your credit card balance at all. If you PPI is added to the monthly payment then your monthly total payment will be higher, but at least you can avoid spending your credit card balance and pay extra in interest. PPI offered by any bank is almost always lot higher than if purchased identical product from an independent insurance broker, just remember to read a small print on your credit card agreement to make a right decision before purchasing.

Credit card interest rates are higher than loans secured with collateral.
Please note this
Above calculation may vary with time and place.
Categories: How & Why Tags:

How to calculate Interest on balances of the Credit Card?

January 19th, 2011 512 views No comments

There are some terms and calculations you must know before paying off credit card bill. Although these terms would be crystal clear to either a financial student or bank employees :-)

What is APR and EAR?

APR (Annual Percentage Rate) is a rate provided to consumer for any balance borrowed from Credit Card. Most common way used to calculate your interest is a daily compounding of the interest based on daily closing balance. This explains the fact about why your interest differ from month to month.

EAR (Effective Annual Rate) is more direct reference for the one-year rate of interest. The formula to calculate EAR is: EAR=((1+APR/N)^N)-1 where N is the number of compounding periods. Lets say that the interest is compounded daily and APR is 16.9% than EAR will look like this EAR=((1+16.9%/365)^365)-1 and willbe 18.41% or if the interest is compounded monthly then EAR=((1+16.9%/12)^12)-1 and will be 18.27%.

credit card

Methods of Calculating Interest

Average Daily Balance

There are few ways to calculate an Interest on the credit cards, but most commonly use is an Average Daily Balance method, which is a sum of the daily balances divided on the number of days within that charging cycle to get an average daily balance, which is then multiplied by an APR divided on the number of cycles within a year which is usually 12.

Monthly Interest Charge=Average Daily Balance * (APR / 12)

This is a pretty good way to calculate your monthly interest, but may not be exact reflection of what you get on your monthly statements.

Daily Accrual

There is also a Daily Accrual method that is commonly used in the UK. This method is similar to the one explained above with difference of calculating interest for the daily balance and compounding it to a periodic (usually monthly) charge. In this method each days closing balance is multiplied on the APR divided on 365 days to calculate daily interest charges. Then all of the daily interest sums are added together.

Formula to calculate daily accrual interest for the period looks like this:

Monthly Interest = (Closing balance day 1 * (APR/365)) + … + (Closing balance day 30 * (APR/365))

Calculation of the monthly interest charges with this method will depend on the number of days within a billing cycle, changes in daily balance and APR.

The calculator above allows for two lines of a credit and therefore calculation of the interest also spreads on two lines, that is calculation of interest on the balance on purchases plus interest calculation on the cash balance, which is usually much higher.

Credit card interest rates are higher than loans secured with collateral.
Please note this
Above calculation may vary with time and place.
Categories: How & Why Tags:

Before choosing credit card

January 13th, 2011 7 views No comments

There are some presentations which can help you opting correct credit card as per your need.

Never forget to read faster way to pay off credit card bill.

Categories: How & Why Tags: ,

How to implement log4j in java code itself without using log4j.properties

January 12th, 2011 613 views 2 comments

If you are not willing to use log4j configuration file ie log4j.properties then you will have to define a java class to set all properties in your code itself.

STEPS

  1. Creating a logger and appender. Add appender to logger.
  2. Set the LEVEL if you want
  3. Define log message layout.
  4. Don’t forget to attach log file path where you have to write your messages.

Sample code: Copy and paste below sample class somewhere in your java project.

public class Log
{
	public static Logger as_looger;

    public Log(){}

    static
    {
        as_looger = Logger.getLogger("articles logging");
//      as_looger = Logger.getLogger(Log.class.getName());
        FileAppender as_appender = null;

            as_appender = new DailyRollingFileAppender(new PatternLayout("%d{dd-MM-yyyy HH:mm:ss} %C %L %-5p: %m%n"), “path of file where to write logs”, "'.'dd-MM-yyyy");
        as_looger.setLevel(Level.DEBUG);
        as_looger.addAppender(as_appender);
    }
}

Since as_looger is declared as static in above example class. So you can use it throughout your java project using class name as follow;

Syntax

< Log class name >.< logger name >.< method denoting a level >(“message”);

Example

Log.as_logger.debug(“article-stack.com has been started.”);
Categories: Uncategorized Tags: , , , , , ,

How to extract all images from PDF in one short?

January 11th, 2011 87 views No comments

If you are a web designer or graphics designer then you must be aware with this trick. But if you are not then it can become very helpful to save your time and effort.

For this, Import your PDF file in photoshop software. From the dialog box appeared, select image option and continue your work.

PDF in Photoshop import dialogbox

Had you fade up with new google image search? Switch to classic style

January 10th, 2011 188 views No comments

Google has changed its display style for image search. They had adopted BING style with popping up images in addition. It displays more result when you scroll down.

Don’t you feel this search is slower than older one? Although their internal searching speed is as usual high but displaying result in front of end-user had become slow. Especially if you are working on a slow machine then you need to switch to classic view.

To switch google’s classic view of image search result, you just need to put “&sout=1” at the end of URL in your address bar. For example; if you are searching images for article-stack, you’ll find following URL in address bar


http://www.google.co.in/images?q=article-stack&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&ie=UTF-8&source=og&sa=N&hl=en&tab=wi&biw=1224&bih=514

google image search new style

Now to switch to classic view just add &sout=1 in last. You new URL would like to be


http://www.google.co.in/images?q=article-stack&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&ie=UTF-8&source=og&sa=N&hl=en&tab=wi&biw=1224&bih=514&sout=1

google image search classic

How to remove multiple blank lines from a document in 2 minutes

December 25th, 2010 1040 views No comments

This is very small trick I tried yesterday while creating a PDF file from a document file containing one blank line after a line containing text.

Well!! If you already had read my article about regular expression then it’ll seem very easy for you. Otherwise you just use it as it is without scrubbing your head. I’ll suggest you to read my articles over regular expression. So that you can create such tricks yourself.

What you have to do:

I am using TextPad for this purpose. You can use any test editor which supports regular expression like TextPad or NotePad++, EditPlus.

Copy paste contents in editor. Open “Find & Replace” dialog box from “Edit” menu. If you are using TextPad then you can press F8 to launch this dialog box.

Paste following text into Find text box

\n[ \t]*\n

And replace it with new line character “\n”. Remember that there is a space before “\t”. In the same way if you want to remove multiple blank lines then use “\n” just after “\t”.


textpad find and replace box

Let visitors read documents without downloading

December 13th, 2010 34 views No comments

There is a very simple solution to display word documents , presentations, excel files etc on your own webpage itself. So people can read them directly without downloading the article and installing any plugin. You can take the help of google for this purpose.

noticeboard embed

For this,

  1. Either upload the documentation file on your server or arrange a link of any other server
  2. Place your link after the given link
    http://docs.google.com/viewer?url=

    For example;

    http://docs.google.com/viewer?url=http%3A%2F%2Fwww.jvds.nl%2Fclimateuncertaintyethics.ppt&embedded=true

Definitely, you would have to use “iframe” tag for this purpose. Read article Highly searched keywords in year 2010 for live demo.


Tip

Instead, if you are willing to display a website, document etc in a popup like thickbox then read the power of wordpress inbuilt thickbox. You can do it without installing any extra plugin.

How to build Microsoft powerpoint presentations easily

December 13th, 2010 52 views No comments

People who doesn’t know how to work in Microsoft powerpoint can refer the below videos. First video will teach you the basic like designing and formatting. While the 2nd tutorial will teach you some advance part like animation and transition effects etc.

This would be a great learning for the people who are lazy to read books or believe in fast learning.
Part 1



Part 2



These videos tutorial will fit to all students of any stream and employees since everyone needs to present their ideas, work and reports in front of their teachers or seniors.

Online Rubik’s Cube game and solver

November 21st, 2010 1447 views No comments

I purchased the Rubik’s Cube a week ago. This could be a favorite time pass for me while traveling. I tried a lot but couldn’t solve it.

Had you stuck while solving a Rubik’s Cube?

Visit this online Rubik’s Cube solver. It can help you to solve 2x2x2, 3x3x3, 4x4x4 type of Rubik’s Cube. You just need to mark colors. And click on “solve” button. It’ll also tell you how did he solved your puzzle. So it is very good for learning.

If you don’t have rubik’s cube with you then you can play it there.

Online Rubik cube game and solver of any size

See the video tutorial for interactive learning.

How to solve Rubik’s Cube 3x3x3

November 19th, 2010 555 views No comments

Finally I found a single video explaining all steps about how to solve Rubik’s 3x3x3 Cube. I liked this video. Because all steps are neatly explained. And you need not to follow any other video sequences.

This video is very good for beginners but little bit lengthy.

TABLE OF CONTENT:

Steps Video Frame position
STEP 1, Cross 3:12
STEP 2, 4 corners and notation 6:15
STEP 3, 4 edges 10:52
STEP 4, edge orientation 14:31
STEP 5, corner orientation 17:48
STEP 6, corner permutation 20:37
STEP 7, edge permutation 22:27
Example Solve 24:59

How to decorate house CORNERS, an interior design

November 15th, 2010 409 views No comments
flower design interior for house corners


If you are decorating kids room or thinking some innovative interior styles then this greeting card style might be a good option for you.

Take a big and colorful sheet. Cut and shape it. Stick the paper sheet in the corner or behind the door. So the flowers can be folded inside when someone close the door.

If you are not able to think any design then you can refer a greeting card. There are many greeting cards available in such format.

How to extract website URL using Regular Expression

October 13th, 2010 818 views 1 comment
I am using Java syntax for this example. You can use AWK, PHP or other language in same way.


http www

String RE = &quot;http:.*\\.[a-zA-Z0-9]{2,4}&quot;;
Regex r = new Regex(RE);
:

Test string 1:

r.search("I am maintaining http:\\article-stack.com. This will help you to learn.");

Output:

http:\article-stack.com

Test string 2:

r.search("< a href='http:\\article-stack.com' alt='nothing'>article-stack< /a>");

Output:

http:\article-stack.com

Consideration:
length of domain type is 2-4 and it contains alphanumeric characters.

Improve previous RE

Valid website name should contains alphanumeric characters and hyphen sign only. And hyphen must not come in starting of website name.

String RE = "http:\\\\[^\-][a-zA-Z0-9\-]+\.[a-z]{2,4}";

Sample text

I am maintaining http:\\article-stack.com. This will help you to learn.
I am maintaining http:\\article-stack.com. This will help you to learn.http:\\-article-stack.com
I am maintaining http:\\article-stack.com. This will help you to learn.

Output:

        (
            [0] => http:\\article-stack.com
            [1] => http:\\article-stack.com
            [2] => http:\\article-stack.com
        )

In addition:

You can modify upper RE for domain since domain name may be in form of “.co.in”.

SQL:How to fetch starting N rows from a table

October 7th, 2010 59 views 1 comment

DB2

		select *
		from 	(select rownumber() over(order by &lt;colName&gt;) as row_num, &lt;colName2&gt;
			from &lt;table name&gt;)
			as &lt;alias name&gt;
		where row_num &lt; N+1 with ur

Oracle

		select *
		from 	(select rowid as row_num, &lt;colName2&gt;
			from &lt;table name&gt;)
			as &lt;alias name&gt;
		where row_num &lt; N+1