JQuery Timer Count Up – Count, Stop, Reset

JQuery Timer Count Up

JQuery Timer Count Up - see demo

Nearly every serious project requires a timer. So here is a JQuery timer count up, with stop and reset built in. Later we will build a timer that keeps track of the difference between two dates/times and saves/loads them in the database. For now, its a simple timer. Follow the link on the screenshot of the timer to see a demo of it in action. Click once and the timer begins counting. Click a second time and it stops. Click a third time and it resets to zero and starts counting again.

Read the rest of this entry »

Windows Hosts File – Edit for Domain Reslution

Redirect Domain Name in Hosts File

Redirect Domain Name in Hosts File

Editing the Windows Hosts File

Sometimes you have a need to edit your Windows hosts file, usually pertaining to the resolution of a web site by means of its domain name. This only affects access by this domain name on this one computer. It does not influence access anywhere on the Internet.

Most users will only need this for the address 127.0.0.1, which is the internal address, or local address, for this computer. Think of this number as a way the computer remembers who it is.

The procedure applies to the Windows hosts file on Windows XP, Windows Vista or Windows 7.

Procedure

Windows Hosts File

Windows Hosts File

The Windows hosts file overrides any other source for resolving a domain name.

  1. Find Notepad in your menu, right-click and choose to Run as Administrator.
  2. Select Open in the menu and change File Type to All Files (*).
  3. Open hosts at C:WindowsSystem32driversetc
  4. Start typing on a new line at the bottom of the file if you want to add a new entry.
  5. If you want to alter an existing entry in the Windows hosts file, edit it directly where it is in the file. I suggest making a comment just before that line, on a new line entered above it and starting with a hash (#), saying that this has been altered. You might even copy the original line and edit the copy, commenting out the original with a hash.
  6. For example, you might change the loopback to this 127.0.0.1    www.yourdomainname.com – after the change, entering www.yourdomainname.com would not take you on the Internet, but to an http server you might have set up in advance on your computer.
  7. Make absolutely sure there are no blank lines at the end of the file or spaces on the end of the last line. Save. Exit Notepad and you’re finished.

Final File Example

Your Windows hosts file, from our example, should have at least the following in it:

# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

#127.0.0.1     localhost
127.0.0.1    www.yourdomainname.com          #This is my change
::1             localhost

An Introduction to Php OOP

Why Use OOP?

Object Oriented Programming

OOP

Encapsulation is a good enough reason to use OOP in your code, but there are additional reasons. First, I’ll explain the concept of encapsulation. It is not unlike the separation of presentation and structure that web programming has undergone in the past few years with HTML and CSS. With that separation we have more clearly seen the need for a glue between the two that provides interaction, which had previously been quite lame. So now we have such projects such as JQuery. But that’s for another day.

Encapsulation keeps the program insulated from the code that is inside the classes. A class exposes its code through methods. The program does not know how a method works, but just that there is such a method and what it requires be sent to it as data, in the form of parameters. This isolation makes it easier to test drive various scenarios of code by swapping out the code in methods inside classes. The rest of the program does not care that you changed how you do a certain method. It only cares that it sent a parameter and received a result. This is also extremely useful and time-saving when hunting down errors in your code. Read the rest of this entry »

Php OOP Tricks – Variables Carrying Class Names and Objects

Object Oriented Programming

OOP

Class by Variable

Normally an object is created in OOP (Objected Oriented Programming) in this way:

$object = new Thing('Hammer', 14);

where Thing is a class that has been defined, ‘Hammer’ is a parameter, such as name, and 14 is another parameter, such as length in inches.

However, it may not be such common knowledge that the class name can be passed by a variable, rather than hardcoded:

$cl_name1 = 'Thing';

$object = new $cl_name1;

This is the same as:

$object = new Thing;

If the class name you pass through your variable is non-existent a runtime error is generated.

Object Reference by Variable

Another, similar technique is that references to objects can be operated on through variables:

$tool = new Thing;

$object = 'tool'

${$object}->init(50000, 1.10);

That would be the same as $tool->init

Property Name by Variable

Php OOP

Php OOP

Finally, property names can be handled in the same way:

$prop2 = 'size';

echo $tool->$prop2;

Introduction to JQuery

This entry is part 1 of 1 in the series Beginning JQuery

It’s here! I promised a set of JQuery tutorials by 12th May and that’s today. Every day for a week I will be posting a new tutorial in the set. I will take you through all the foundational issues to programming your website or web app in JQuery. Yes, web app! It is almost as easy to create a web app with JQuery as it is to make a website.

JQuery & JQuery UI Tuts @ Znovu.com

You will need to have knowledge of HTML and some CSS. All the other languages we will need I will introduce as we get to them. Don’t worry, though. I’ll make it easy as pie. Speaking of easy, most tutorials are written by programmers, for programmers. That’s not how these are. I have tested them out on my artist girlfriend and she is able to follow them, so I think you will do just fine. Here are examples pages of what we will accomplish in this series.

JQuery, as a language, is able to control HTML and CSS, but it also talks with Php on the server. That means it has access to Php’s facilities to communicate in SQL with a database server, through JSON. So JQuery has everything at its fingertips. If you didn’t understand those acronyms I just spewed out, relax. They will be names you’ll become familiar with and will even learn how to use a bit here and there.

Our goal is not to make you rocket scientists, but to put a powerful tool in your hands to get your dreams moving along. What you do with them will only be limited by your imagination. Read the rest of this entry »

JQuery Series Coming in 3 Days!

Beginning JQuery – Start Off Right!

Bob Tech's JQuery Tutorial Series Launch

JQuery Tutorial Series Launch Date

This is a new series that will introduce the beginning JQuery user to a simple and powerful system of constructing either websites or web apps with JQuery and JQuery UI’s libraries.

The only languages you need to know are HTML and CSS. We will introduce you to JQuery and JQuery UI. You will also learn some AJAX, JSON, Php, and SQL as you need them. The lessons are for the absolute beginner, but take you to the Intermediate level quickly and easily. We ignore the trifles that programmers love arguing about and focus purely on the practical.

The first six lessons are complete and we stand ready to release the first pack, complete with demo pages of the exact code you learn in the tutorials. We estimate the series will hit the pages of Bob Tech within 3 days!

Watch for it on Thursday, 12th May 2011 !