Friday, August 24, 2012

Yu Wenxia is Miss World 2012

The 23-year-old Yu Wenxia has been crowned the Miss World 2012 title. She is the second Miss China to secure this honour for her country. She is from Heilongjiang province in the northeast. She has studied music and hopes to become a teacher of the art one day. She is adept at singing and playing the piano.She is also noted for her opera talents.

Miss World 2012

Miss World 2012

Miss World 2012

Miss World 2012

Miss World 2012

Miss World 2012

Saturday, August 11, 2012


Now, it is the Ramadan season, the month-long fasting for the Muslims. Everyday their start  and ending time for fasting (Sahri and Iftar, respectively) is not the same. It changes due to the change in sunrise and sunset time. It is something that is impossible or somewhat illogical to remember. So for the users' convenience I have created a code which will automatically give users the time of Sahri and Iftar for that day. And moreover, it does not require you to mumble with the MySQL databases or tables. It works based on a CSV file which we use to store the times for everyday.

Step 1: Create the data (but no database!)

Let's say, we are a little bit lazy for creating a database for this widget sort of thing. And besides, it is for one month only. So, we are going to store our time data in a .csv file. .csv files are easy to edit with any spreadsheet editor such as, Microsoft Office Excel, LibreOffice Calc, OpenOffice.org Calc etc. You are required to start your spreadsheet program then create a sheet like as follows (if you can't make this, download the source zip and get a copy of it):
Sahri Iftar time php widget csv storage
We have 6 columns: roza, day, month, year, sahri, iftar

roza: the serial number for the roza.
day, month, year: the date to which the roza is for.
sahri: time for Sahri.
iftar: time for Iftar.

Now that the csv file (or in our case the flat-file database) is ready, we can move on to the next part.


Step 2: Download CSV parser class

You can google for a php csv parser class, but mine seems to be working fine. So I am going to use "parseCSV" for getting our data from the csv file.
  1. Go to http://code.google.com/p/parsecsv-for-php/
  2. Go to Downloads link and download the class package.
  3. Extract the package and copy parsecsv.lib.php file to your working folder/directory

Step 3: Write code

We are using PHP for coding. So here is an example php file for simple usage.

<html>
<body>
<?php

require_once 'parsecsv.lib.php';

$csv = new parseCSV();
$csv->auto('timesdb.csv');

$search_day = date('j');
$search_month = date('n');
$data = $csv->data;

for ($i = 0; $i <= count($data) - 1; $i++) {
    if ($data[$i]['day'] == $search_day && $data[$i]['month'] == $search_month) {
        echo '<h3>Today ('.date('d-m-y').'):</h3>';
        echo '<p>Sahri: ' . $data[$i]['sahri'] . ', Iftar: ' . $data[$i]['iftar'].'</p>';
        echo '<h3>Tomorrow:</h3>';
        echo '<p>Sahri: ' . $data[$i+1]['sahri'] . ', Iftar: ' . $data[$i+1]['iftar'].'</p>';
    }
}


?>

</body>
</html>

Conclusion

Well, there you have it! A Sahri and Iftar widget for your website which requires no database. We use 3 files: (1) the CSV file, (2) CSV Parser, (3) PHP file. You may store the class file and the data file in separate directories for the sake  of clarity in your project's directory structure.

Here is the download link to the source files: http://www.divshare.com/download/19329139-21d

Feel free to comment in case you need any help or have a way to improve it.

How to add a network printer in Windows XP & Windows 7?

Method - 1 
Installing a network printer to a Windows XP machine from another XP-based computer is very simple. You can do so by following the under-mentioned steps:

Step-1
 
First make sure that the printer attached on the XP machine is shared.

Step-2

If the printer is not shared then go to the computer where it is installed.

Step-3

From Control Panel open Printers and Faxes.

Step-4

Right click on the printer and choose Sharing to open printer Properties.



Step-5

Then click the Share this printer radio button and give the printer a share name.



Step-6

Now go to your own XP machine, i.e. from where you wish to connect to this printer.

Step-7

Open the Start menu.

Step-8

Click My Network Places.

Step-9

Under Network Tasks, click the View Workgroup Computers.

Step-10

Under Other Places, click Microsoft Windows Network.

Step-11

Now find the right XP computer where the printer is installed.

Step-12

Right click on the printer and click Connect.



Step-13

Follow the onscreen instructions to finish connecting to the network printer.


Method - 2
This method is especially applicable when you want to install a network printer to a Win XP machine from a Windows 7 machine:

Step-1

Go to Control Panel.

Step-2

Open Printers and Faxes.


 
Step-3

Under Printer Tasks, click Add a printer to open the Add Printer Wizard, and then click Next.



Step-4

Click the radio button entitled A network printer, or a printer attached to another computer, and then click Next.



Step-5

Click the Browse for a printer radio button, set the printer location, and then click Next.



Step-6

Find and select the desired printer.



Step-7

Follow the onscreen instructions to finish connecting to the network printer.



Again, If the printer is installed on a Windows 7 (X-86 or x-64) machine and you want to connect it on a XP machine then just repeat the above instructions.

Follow Us

Blog Archive

Popular Posts