Generate a simple line graph with Pure PHP

You might want to generate a dynamic line graph to show some statistics, you don’t want to involve yourself into lot of tricky programming? Then let’s just use the PHP GD and Image Functions to do it.

Open a PHP page and add this code:


header(“Content-Type: image/png”); //this will set header as png image

$im = @imagecreate(800 , 600) //this is size of the canvas

or die(“Cannot Initialize new GD image stream”);

$background_color = imagecolorallocate($im,255 ,255 ,255); //background color as white
$black = imagecolorallocate($im, 0, 0,0);

imageline($im, 80 ,480,650,480, $black); //this for x-axis
imageline($im, 100,40,100,500, $black); //this for y-axis

//division on x-axis
$x_add = 50;
for($i = 0; $i <= 9 ; $i++){
imageline($im, 150+($i*$x_add), 480, 150+($i*$x_add) , 500, $black);

//division on y-axis
$y_add = 40;
for($i = 0; $i <= 10 ; $i++){
imageline($im, 80, 480-($i*$y_add), 100 , 480-($i*$y_add), $black);

$names_on_x_axis = array(1,2,3,4,5,6,7,8,9,10); // here is where you put the names for values on x-axis
$values_on_x_axis = array(1,2,30,4,5,50,7,8,9,10 ); //put the corresponding value
$y_axis_initial = 1; // here is where you put initial value for y-axis
$y_axis_interval = 10; // here is where you put needed interval value for y-axis

//write values on x – axis,
for($i = 0; $i <= 9 ; $i++){
imagettftext($im, 12,270, 148+($i*$x_add) , 508, $black, ‘font.otf’,$names_on_x_axis[$i] );

//write values on y-axis
for($i = 1; $i <= 10 ; $i++){
imagettftext($im, 12,0, 50 , 485-($i*$y_add), $black, ‘font.otf’,$y_axis_initial + (($i*$y_axis_interval)-1) );

//calculation part
$total_height = $y_add * 10; //height of graph

//this function will calculate the height for the points
function needed_height($input_value){
global $total_height, $y_add , $y_axis_interval ;
return 480-(($input_value/$y_axis_interval)*$y_add);}

//now to draw line graph
for($v = 2 ;$v<=10 ; $v++)



and save this page.

You can change values and names for the values by changing the values in arrays named “$names_on_x_axis” and “$values_on_x_axis“,

to change y-axis interval and values edit “$y_axis_initial” “$y_axis_interval“.

[HOW TO] Use fastboot to flash android factory images on nexus devices

You will need to have latest android SDK tools installed on your computer in order to do this. Download the SDK from here

Download the latest factory image from here,

(Before continuing back up all the files and also know that you are also risking your device)

and extract all files from zip and place them in android platform tools path.

adb path

Now connect your nexus device to computer using USB cable and open command prompt window and type in ” adb devices “. See if your device listed under the list. If it listed then we can move on.

If the device is not visible under list, then see if you have installed the drivers properly and if you have the latest adb tool version. To check the adb version type in “adb version” and hit enter. Mine is 1.0.31 and it worked really well with it.

If your nexus device has been listed then type this command to open bootloader in device.

Adb reboot bootloader

Now after sometime your phone must start in bootloader menu. After, type


fastboot oem unlock
fastboot erase boot
fastboot erase cache
fastboot erase recovery
fastboot erase system
fastboot erase userdata
fastboot flash bootloader your-bootloader.img
fastboot reboot-bootloader
fastboot flash radio your-radio-image.img
fastboot reboot-bootloader
fastboot -w update


for my nexus 4 occum image it went like this.


fastboot oem unlock
fastboot erase boot
fastboot erase cache
fastboot erase recovery
fastboot erase system
fastboot erase userdata
fastboot flash bootloader bootloader-mako-makoz20i.img
fastboot reboot-bootloader
fastboot flash radio radio-mako-m9615a-cefwmazm-2.0.1700.84.img
fastboot reboot-bootloader
fastboot -w update


Now your device will start with factory image, configure it as you want.


Now Track, Ring, Erase, Lock your Android devices remotely using Android Device Manager

Google has now allowed android users to lock, erase the data, ring, track their android devices remotely using the web. You can simply do it by logging with the same email id as used in android device and open this link,

google android device manger map


By default LOCK and ERASE Feature is disabled, casino You can enable it by going to

Google Settings -> Android Device Manger -> and Tick Allow remote lock and factory reset right. Remember after enabling it, use it carefully, you may end up losing everything on your device.

Latest Android Factory Images for nexus devices.

Here are android factory images for nexus devices, these are useful if you have flashed with any other roms like AOSP , Cynogenmod or other android custom roms and you want to return back to the factory rom.

You will need fast boot tool to install factory image.

(HOW to use fastboot to flash android factory images on nexus devices, tutorial coming soon)

here you can find factory images :

[How to] Flash Android factory images to Nexus 4.

Yesterday I flashed Android 4.3 to my Nexus 4, I waited for long to get the update on air, but I couldn’t wait any longer. It was not easy to get it all together and flash it. I went to many tutorials and articles, all they did was totally confuse me. So first, I tried to flash update package, I failed due to complication, I tried side load method, CWM flash and all, it merely failed. So, I choose to flash factory image. There were tutorials which were bit head cracking. But, I found a tool to do it. It was, easy and quick. This tools is called Nexus 4 Toolkit, it can be found here, or you can directly download it from here

Here is how we flash the factory image. First, download the app from the links above.

And make sure you have installed all the required drivers for your phone.

Download and install Android SDK tools from here . (We will use to check the devices)

Unlocked the phone.

After installing and everything, connect you device using USB cable and enable USB debugging mode on your phone. You can do it by Settings  -> Developer options -> USB Debugging enabled. Don’t see “Developer options” ? then go Setting-> About Phone -> And tap on Build Number for several times, now it will show up.

Now, open a command prompt window in the same folder as the adb.exe and fastboot.exe Continue reading [How to] Flash Android factory images to Nexus 4.

Beginers! step into advanced level programming.

Have you just completed basic programming? you can create simple programs? that is not enough, world expects experts. So, don”t stop at that level, you got to push yourself to next level, start programming more advanced and complicated things. Improve your coding standards.

How do you do that? Here are somethings you can do to improve yourselves with coding.

DRY programming

DRY(Do not repeat yourself) programming. This method means that you must avoid writing the same code over and over again. This reduces the file size and also increase standard, performance, readability, and adaption of the program. This is the one thing that will make you look very professional.

How to do this? well, you must start learning functions and OOP(Object-oriented-programming) programming. This will help you to avoid the repetition of code.

Maintain neatness

Neatness is one thing most needed in programming to make others understand what you have done. It will be impossible to other to trace your steps of the program, not only others maybe also for you, if you don”t maintain neatness and organization.

If possible, leave comments, it won”t eat much space!!! . Comments help others and you to know what that certain part of code does in the program, it will be of a lot of help if it is a big program, it will be easy to get back to coding without checking hundreds of lines and your personal dairy.

Use frameworks, plug-ins, external libraries

You don”t have to write everything from zero, there are people who are willing casino online to give you their works for free to use. All you have to do is edit it according to your needs and add some of your lines, that”s all.

Frameworks, these are programs or scripts which are meant to be linked to your code. When you link them, they have already written function which you can access easily in your code. They ease the coding  processor and also have performance optimizers. If you are not to approach OOP, then this would be a fine solution.

Plug-ins, plugins are same as the framework but it is a simple single function, it does only one or some related things. It is also linked to your program and accessed.

External libraries, these are libraries for programming languages. These are are directly inserted into programming language. when you think your programming language doesn”t have certain abilities then you must find libraries for it.


New good smart phones under 20k Rupees

Many smart phones have been released and all phones are not affordable, but here are some good and affordable phones available to buy. The price range is very less, about to 20,000 rupees.

Lets start with

Samsung Galaxy Grand GT-I9082

SAMSUNG galaxy grand duos


Holding this phone up in your hand is almost same as holding a Galaxy S4. It has same screen size as S4, that is 5″ touch screen, and it has a resolution of 480×800 pixels. The phone is powered up with a Dual-core 1.2 GHz Cortex-A9 processor, and has 1 GB of ram, which would decently run any application without a lag. This phones comes with a 8MP rear camera which also supports full HD video recording @30 fps. It has a front camera of 2MP, which is really good. Grand has an internal memory of 8 GB and also can be expanded Continue reading New good smart phones under 20k Rupees

SEO for Bloggers.

SEO isn’t that easy for web bloggers. Making pages look good in search engines is harder than anything, they keep swinging from first page to the hundredth page. So, bloggers usually keep researching on the web to keep the ranks higher. They get lucky sometimes, most of the times they are failed. Well, not because they didn’t try hard but sometimes they have to make changes on their own web to make it more SEO friendly. Here are somethings you can before posting on your blog.

seo for bloggers

Tags, Tags, Tags

Tags speak everything for SEO sometimes. You must be really good at choosing tags. Choose tags which are related to your posts and also very popular or common. For example, if I write about an car, I would tag it under “cars”,”brands”,”name-of-the-car”, not only these but, “mileage”,”smooth running car”,”new car”, etc.

Though your page does not has the search term, your page will be showed up in search engine if it has tag which matches the term . So, always choose a tag that is common or popular.

Use Images wherever possible

Use images in the posts wherever possible, and give alternative sensible names to the images  because images also drive a lot of traffic to the blog, if you post some appropriate image with right name, who knows, you may drive thousands to your site easily.

Ping back your previous articles,

If there is something you written already related to currently being written articles then you must mention them. Because, when you mention the articles again they get re-crawled and they get a bit boost of SEO, which is a good thing.

Keep up the posting frequency,

You must maintain the posting frequency, if you stop posting even for a week your blog may jump back to many pages behind. So, never miss an opportunity to post something on your blog.

Maintain originality

Original articles are found to be more focused and most easily reached. Powerful and unique articles are good way to attract users.



Create a side hover menu for your site with pure CSS

Create a nice and attractive side hover menu for your website with pure CSS. It will let you store menu items in it and only show when user move the mouse towards any edge of the screen. Here I am creating a left-sided menu.

Lets first prepare a HTML page with menu,


Now lets start playing with css styling, Continue reading Create a side hover menu for your site with pure CSS

Username availability checker with PHP and jquery

Do you want to tell users while registering if the username they have typed into input field is available or is taken already before they submit the form? Well, it can be easily done with PHP and jquery, it takes no more than few lines.
Username availability checker with php and jquery

 First set a HTML form like this and save it as form.html

Do not forget to attach jQuery script, because it is where the magic lies

Now set up the php page, it is the place where the username availability will be checked

Code goes like this

Continue reading Username availability checker with PHP and jquery