Saturday, April 4, 2015

Adding Base64 Encoded Images To Jasper Reports

Base64

Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. This method can be used to transfer binary data as textual data. Click here to read more on Base64

Adding To Jasper Reports

If you need to add the image through a URL(or a file location) to the report you can easily do it by going through image properties. But if you need to set the image through a Base64 encoded character string then you need to add it to the report as shown below.

Assume that the parameter for the Base64 encoded string is 'p_logoURL'. Then you can add this parameter to the image expression as shown below.

Image Expression
That's it. You can see the image in your report.

Sunday, February 22, 2015

How To Create A Windows Batch File



Batch files are used to store DOS commands. Once you run the batch file by double clicking on the file or via any other method such as using command prompt, all the DOS commands are executed sequentially. Normally batch files are mostly used to automate repetitive tasks.  You can save your time by automating repetitive tasks. This method is very useful for developers more than normal computer users.

Creating a batch file is not a complex task.  You need to know only the DOS commands that you are going to put into the batch file and the order of the commands.

Here you can see few of commonly used DOS commands.

  • TITLE      Window name when bat file executes.
  • PAUSE    :  Pause the execution of the bat file and wait until user press any key  to continue
  • CLS        :  Clear the DOS window
  • MKDIR    Create a directory
  • DIR         :  Move into a directory ( “DIR directory_path”) or view current directory (“DIR”)
  • START    :  Execute a file using default application
  • ECHO      :  Print something on the command prompt window
  • ECHO OFF    :    Prevent showing the batch file commands on the command prompt
You can find a list of DOS commands by typing HELP in command prompt 

Let’s create few batch files.

After understood basics you can create complex batch files by adding various commands. First you need to create a file with .bat extension or .cmd extension.

Open notepad --> click save --> select all files --> name it as test.bat or test.cmd --> save





Now you can insert below DOS commands into your file and test them.

1.  A program to create a directory
       MKDIR  Hello_World
       MKDIR “Hello World”

Insert above commands into your test.cmd/test.bat file and save. Then execute these commands by double clicking the on the file. Keep in mind to put double quotation marks if you use spaces in a name.
Above commands will create two folders called Hello_world and Hello World in the same directory where your batch file exists.


2.       Create a text file with a text string
MKDIR “text folder”
CD "text folder"
ECHO "This is the text string" > textFile.txt

This DOS command will create a folder named text folder and create a file named textFile.txt and write a text string into the file.

You can understand the basics of creating a batch file using above examples. Once you got the basics you can create very complex files to automate a process.
Click here to read more on this topic.


Sunday, February 1, 2015

Create Your Own HTML Tags



You might be programming with html and may be thinking how to create your own html tags  to use in html code. This is a very easy task. First you need to define a name for your tag. You should be careful not to use any html reserved words. Assume you have named your tag name as mytag. Use it in the html code as a normal tag.(write opening tag and closing tag)

<mytag>

</mytag>
 Now you need to provide attributes for the tag that you have defined. You can add these attributes using CSS.
<style type="text/css">
     mytag{
            background-color: lawngreen;
            padding : 10px;
            font-style : italic; 
          }
</style>
Now you can use your tag as a normal html tag and  use it in your html code.
Complete code :
<!DOCTYPE html>
<html>
    <head>
         <style type="text/css">
             mytag{
                 background-color: lawngreen;
                 padding: 10px;
                 font-style: italic;
                  }
         </style>
    </head>
    <body>
        <mytag>
            hello world
        </mytag>
    </body>
</html> 

Monday, July 28, 2014

.Net Framework Web Browser Class


Web Browser class is one of the most important class provided by .NET Framework for tasks related with web. It has lots of methods which can be used to implement web related tasks such as web scraping, creating a inbuilt browser in a software and many more.

Now I am going to let you know how to create program which will search a given word in yahoo search engine using this WebBrowser class. The language I am using to explain is C# here but you can use languages as visual C++, F#, VB as well.
You need to have some knowledge about C# and HTML before begin to do this task because almost all the things are represented in HTML in a web page thus you need to have an  understanding about HTML. Also if you do not know anything about C# then you are again in trouble. Therefore the prerequisites are C# (I am using Visual Studio 2013 IDE)  and HTML.

Lets get into work,

open visual studio and go to New => project => select windows forms Application under C#

Then you will see a windows form appear with title Form1. Now drag  a "button", "textbox" and a "web browser" from the tool box.


 Set the URL of the web browser as https://www.yahoo.com and text of the button(not the name) as "Go".
you have to make sure that the names of each component were not changed.
web browser name  : webBrowser1
button name            : button1
text box name         : textBox1

Now click on the text box and set TextChanged event as shown below:


just double clik on the TexChanged event(highlighted in yellow).

then a new file will be opened(Form1.cs)  and you will see a method called "textBox1_TextChanged".

 Now always when we  type something on the text box, this method is invoked. What we expect from this is when we type something on the text box it should be appeared on the search box of the yahoo search engine. Now we place a code inside textBox1_TextChanged method to do this task.

How it looks like after adding the code

The piece of code we used it shown above. Now your basic HTML and C# knowledge will help you to understand what happened and I will explain how we got the element ID.(p_13838465-p).

go to the shown link using your web browser. https://www.yahoo.com

now right click on the search box and click Inspect Element (I assume you know these things)

Finding ID of the search box

Then you will see the ID of the search box.

Our next step is setting the "go" button in the windows form work as "search web" button in the web page.

set button click event handler on the "go" button or just double click on the "go" button to set it automatically. set following code to the button1_Click method.

You can find the ID of the search button by the same method used to find the ID of search box.


This is all with coding and now you can test your program by running the code.

When you run the program you will see the web page is loaded into the web browser window.

Then type anything in the text box of the program, then you will see same text appears on the search box too.

When you click the "go" button it will search the web with the entered word.

I hope now you got an idea about some of usages of the web browser class. Like this you can do lots of advanced things with using this class.

Comment below If you have any question regarding this program.

Saturday, May 31, 2014

How to create c++ header files and make them work in ubuntu

You can easily create header files in c++ and work with them using an IDE(Integrated Development Environment) such as CodeBlocks, Eclipse, etc. If you are using an IDE, you just need to create the relevant files( such as header file, implementation file and main file) and compile them directly using the IDE. so when you give the compile command  the IDE care the rest of the tasks and give you the output.

But if you are going to do this task in a terminal(ubuntu) without using any IDE then you will have to do these all the steps done by the IDE manually. Therefore here is explained how the same thing can be done by using terminal.(only the steps are shown and not in much details)

step 1 :

You need to create the header file as you need
(a sample header file is shown below)

// rectangle.h  (begining of the file)


#ifndef _RECTANGLE_H
#define _RECTANBLE_H


double area(int length, int width);
// initialize any functions as you need
#endif


// end of the file

you need to save this as a header file.(rectangle.h)

step 2 :

Now you need to create the implementation file.
(a sample implementation file is shown below)

//rectangle.cpp (begining of the file)

#include <iostream>
#include "rectangle.h"

using namespace std;


double area(int length, int width){

    return length*width;

}


// end of the file

you need to save this file as a c++ file (rectangle.cpp)


step 3 :

Now you need to create the main file
(a sample main file is shown below)


// main.cpp  beginning of the file

 #include <iostream>
#include "rectangle.h"

int main(){

    std::cout<< area(4,4);

    return 0;

}


// end of the file

you need to save this file as a c++ file (main.cpp)

step 4 :

Now you can run these files on terminal.

put all the above 3 files into a same folder. then open terminal and go to the folder where these 3 files reside. (using "cd" command   eg : "cd Desktop\header_test_folder")

first you need to compile all c++ files.
type bellow command for each c++ file

g++ -c filename.cpp
 //other cpp files (if any)
g++ -c main.cpp

example : (for above files)

g++ -c rectangle.cpp
g++ -c main.cpp

now you need to link these files and create the executable file.
so you need to run below command for that.

g++ -o finalfilename main.o filename.o  // otherfiles.o (if any) 

example : (for above files)

g++ -o finalrectangle main.o rectangle.o

now you can see there is a new file in your directory(finalfilename)
you need to run that file

./finalfilename

for above example

./finalrectangle

now it will be running on the terminal.









Sunday, February 16, 2014

Assemble Your Dream PC



Hello friends, today from this short article I am going to describe  about pc configurators.  Actually there is a dream computer in everyone's mind. Which may be powerful pc with high performance with magnificent components.


Now you are capable of assembling your dream pc virtually. That means now you can make your dream computer virtually using desired components. so after creating it you can see how it looks like and know the total price of the computer.

This virtual assembly can be done using a pc configurator software which is available online free of charge. So you can build any computer you like and get an understanding about that computer. I have provided some links of pc configurators. Now you can go to those web sites and begin building any pc you like.

 PC Configurators

  Artilces You may like  :  Cloud Gaming   Blu-Ray Disc


Sunday, December 29, 2013

True Backlinks Detection

This post is specially dedicated for Bloggers and for those who are willing to begin blogging. The word "backlink" is a very familiar word with every blogger. There is no blogger who does not know about this. So I am not going to explain it now. As many people say, the most common method of making backlinks is commenting on other blogs. If you have searched on internet "How to increase the rank of a website/ blog ?", 99% of websites says that comment on other blogs and it will make  back links to your blog and large number of backlinks will increase the rank of your website. Some people says that make 50 comments per day then 1500 per month, etc.


But unfortunately the matter is that "Do really those comments make backlinks to your blog/website ? ". Most of people think that once a comment is created automatically a backlink created but unfortunately most of time you are just wasting your time. Because search engine crawlers do not go through those links(web addresses) which you have put with your comment.

How Does This Happen ?

If you have observed the HTML code of a link it looks like this:

<a href=”URL”>Link Text</a>

Link Text appears on the web page and when you click it the Web browser loads the content of the URL. This is a real backlink if your link appear on a web page with above format then search engines accept that link as a backlink.

But most of comments you put are in the below format.

 <a href=”URL” rel=”nofollow”>Link Text</a>

in this case also your link is shown on web pages but you can see there is a special tag called "nofollow". Because of these tags search engines just go through your link but does not consider as backlinks.

Why do they use "nofollow" tag ?

Most of people comment on other blogs not to admire them. Commentators need just to add a backlink to their blog/website. Sometime they comment without even reading the content( You might have seen many comments such as "A great post", "Thank you for posting these content", etc these comments are put just to generate backlinks). To prevent these things and spams, blog/website administrators use "nonfollow" tag. The comment remains but does not make a backlink.

How to detect whether my comment makes a backlink ?

There are many methods of detecting true backlinks. i will teach you a methods to detect which web browser independent.

step 1 :  go to the comment section of the blog/website that you are going to comment



step 2 : Then right click on a comment someone has posted already



step 3 : Click "inspect element" (This option is available in many web browsers, I have tested this
             in firefox, chrome and internet explorer)





when "inspect element" is clicked  the web browser loads the html code as shown below


As shown on the above image. The HTML code of the link is shown in a highlighted line. In this example you can see there contain the nonfollow tag. if  the highlighted text contain nonfollow tag then your comment does not make a backlink it just a comment. If there is not a non follow tag then it creates a backlink.

I hope now you have the ability to check a true backlink. The advantage of a comment is that even though it is does not create backlinks, it makes human readers aware about your blog. If you have any problem regarding this post put a comment.