jQuery Intro

jQuery is a very useful javascript library. It provides unified methods to assign event handlers, perform ajax requests, change CSS classes, etc. All of these operations, using jQuery, are performed the exact same way no matter what web browser the end user is running.

Selecting DOM Elements
Before you can do almost anything, you’ll need to select an element to work with. Normally, this is done by by using

document.getElementById('some-element')

But jQuery has an easier way.

$('#some-element')

This  does the same thing as the previous example. When using a #, you are selecting by id. This is just like a CSS selector.

Keeping with the CSS selectors, using a period (.) at the beginning selects all elements with that class name. Also, putting an element name selectes that element. Separating selectors with a space, denotes a ancestor/descendant relationship. Separating selectors will a comma, elements matching any of the selectors will be selected.

Event Handlers
Assigning an event handler is a lot easier using jQuery. Once you have selected your element(s), run the function mousedown to add a mousedown event handler. For example,

$('td').mousedown(handler);

Adds a mousedown event handler (handler) to all td elements.

In addition to the ease of assignment, the event object passed to the handler is the same across various browsers. There are a few caveats, but the jQuery crew is working to resolve these.

Manipulating Classes
There are several functions for manipulating classes, including removeClass, addClass, and toggleClass. These are fairly self-explanatory. Running removeClass with no arguments removes all classes from the selected element(s).

Ajax
jQuery makes Ajax very simple. To do a post, all you need is:

jQuery.post('/path/to/post',{data1:'hello',data2:'world'})

Gets are even easier:

jQuery.get('/path/to/get').

That’s jQuery in a nutshell. There is much more you can do with jQuery that wasn’t covered. jQuery has a whole set of UI controls available, but these increase the amount of code & CSS that your end user has to download.

For more information, visit http://www.jquery.org/.

Bit Torrent Introduction

File sharing has been around for over a decade and every few years there is a new method of sharing files.  The current popular method is called  bit torrents.  It is fairly easy to get started with bit torrents, and I will show you how.

Steps to get started

  1. Download and Install uTorrent from http://utorrent.com/
  2. Find a .torrent file on the web, googling should be adequate.
  3. Open the file with uTorrent and the download will begin.
  4. Once the download is finished, right click on it and left click on open containing folder to access your download.
  5. Scan the contents of that folder with your anti-virus.

Notes

  • Closing uTorrent will not exit the program.  It will have an icon next to the clock in the bottom right of your screen.  The icon is a green square with a “u” in the middle.  Right click and exit to exit the program entirely.
  • There are a lot of options in uTorrent.  The most important are upload speed (set to 30KB/s or less for cable/dsl), encryption (set to required), and the download folder.

Warning!

Some sites, such as http://thepiratebay.org/ have illegal torrents and I am in no way suggesting you download anything illegal as it infringes copyrights and may contain viruses or other malware that can take over your computer or possibly steal your personal information.

How to get followers on twitter

I’ve spent the last 5 days on twitter and I’ve got 1,661 followers so far.  Here are the steps I took:

  1. Create a new account on twitter.com.
  2. Follow everyone on this list: http://socialnewswatch.com/top-twitter-users/.  Most of the people will follow you back, plus you will get followers that watch these users.
  3. Interact with the people you are following.  Answer someone’s question, post a twitpic, RT(retweet) someone’s post that you like.
  4. Follow everyone that follows you.  Do this 3-4 times day.  Use http://huitter.com/mutuality/ to follow those following you.
  5. After 2 days, use the mutuality tool to unfollow people who are not following you.
  6. Find someone who shares your interests and follow some of their followers.
  7. Repeat steps 3-6.

That’s it.  If you have any questions, feel free to  leave a comment or tweet @compguyaug.  Happy tweeting!

Learn to program through Project Euler

About 6 months ago, I was surfing and came across a math/programming site that has fascinated me ever since, Project Euler. They have over 200 problems to solve and continue to add more. The problems start off very easy and get difficult rather quickly. Some of the beginning problems can even be solved using paper and pencil.

If you are just starting to learn computer programming, you should check out this site. The first problem can be solved fairly easily, and I will show you how I did it in perl.

First, let’s look at the problem. They want you to “Find the sum of all the multiples of 3 or 5 below 1000.” What the program will have to do is loop through all whole numbers from 1 to 999. Inside the loop, there is a check to see if the number is a multiple of 3 or 5. If it is, it is added to the sum. After the loop, print the sum to the screen.

Here’s the code:


$sum = 0;
$counter = 1;
while( $counter < 1000 ) {
if ( $counter % 3 == 0 || $counter % 5 == 0 ) {
$sum = $sum + $counter;
}
$counter = $counter + 1;
}
print "The answer is $sumn";

This program, just like every other computer program, uses flow control. Basically flow control tell the computer what to do and when to do it. There are 2 flow control structures here, a while loop and an if statement. Both of these are started by a comparison inside parenteses, then an opening curly brace. They are ended by the closing curly brace.

The while statement should be fairly straightforward, but the if statement is a little complex. The percent(%) sign means modulus(mod for short), which is simply the remainder of division. For example, 4 % 3 is 1, 4 % 5 is 4, and 9 % 3 is 0. The double pipe(||) means OR. When reading line 4, you say “If counter mod 3 equals 0 or counter mod 5 equals 0, then.”

Let’s go line by line.

Line:1$sum = 0;Set a variable named “sum” to 0.
Line:2$counter = 1;Set a variable named “counter” to 1.
Line:3while( $counter < 1000 ) {Start a loop and continue the loop while counter is less than 1000.
Line:4if ( $counter % 3 == 0 || $counter % 5 == 0 ) {Check to see if the remainder of counter divided by 3 is zero OR the remainder of counter divided by 5 is zero.
Line:5$sum = $sum + $counter;Add counter to sum if so.
Line:6}Close the if block.
Line:7$counter = $counter + 1;Add 1 to counter.
Line:8}Close the while loop.
At this point, the program will repeat the check at line 3 if check is true goto line 4.
Line:9print “The answer is $sumn”;Print the answer to the screen.

You can download perl from perl.com. Once it is installed, you can copy and paste the source code into notepad and save it as euler-1.pl or whatever you want. To run the code, double click on the file.

Play around with the code. Poke it. Prod it. Change the while comparison so it only goes to 10, 100, 100000, etc. Changed the if to check for numbers divisble by 2 and 3. If you mess it up, copy and paste the code back into the file.

If you have any problems, leave a comment.

Web 2.0

When the internet first began, most of the pages were static and didn’t change unless someone manually edited the HTML. Recently, more and more sites have become dynamic. Blogs, Forums, Social Networks, and Wikis have contributed to a movement on the internet dubbed “Web 2.0”. Basically, Web 2.0 refers to website that allow regular users to read and write content to the web.

Forums were the first big step. Forums just let people post questions, answer questions, and share ideas with others. These have been around since the late 1980s when people did not have access to the internet.

Blogs are newer than forums. A blog is simply a self-publication for the web. You can create a blog for any topic you can think of. The blog writers create content and many blogs supply a comments section for feedback, so users can read the blog, then write their ideas.

Wikis, such as Wikipedia, are collections of content. A user can read, edit, and create articles. Then that information is out on the web for anyone to read. Wikipedia is the most popular wiki containing millions of articles on a variety of subjects. Because anyone can edit or create content, the content is almost guaranteed to be up to date.

Social Networks provide a way for real world and internet friends to communicate online very easily. These sites boil down to the simple fact that a user has a set of friends and can send them messages as well as having a profile page. Some sites serve a particular purpose, like delicious is only for bookmarks.

I hope this clears up any confusion about what Web 2.0 is.

Click Happy? Be Careful!

Some people are click happy. They click on ads, off-site links, and things they shouldn’t click. Are you one of those people? If so, here are some guidelines to keep your information and your computer safe.

The majority of sites on the internet, this site is no exception, use ads to offset the time and money put into the site. Sometimes the ads are labeled. Sometimes they aren’t labeled. An easy way to find out is to run your mouse over them and look in the status bar. If the status bar starts the same as the address bar, you’re pretty safe that it’s not an ad.

Don’t get me wrong, ads can be quite useful. Personally, I would never click on an ad unless I knew it was a google ad or knew the site was reputable. When I say reputable, I mean an organization or person who filters the ads, such as <a href=”http://www.thesimpledollar.com/”>The Simple Dollar</a>.

Those listing at the top of search results are hardly ever what you need, but when they are you should use those. The listings at the very top are paid for, and clicking on them helps the search engine to earn some much needed money.

Finally, there are plenty of malicious sites out there. They want you to visit their site using IE6 pre-XPSP2, if you don’t have SP2 DOWNLOAD IT NOW. When you do, they install software that tracks your every click and keystroke. It’s pretty scary if you ask me. I wouldn’t want someone to know my login information for <a href=”http://www.amazon.com”>Amazon</a> or much less <a href=”http://www.paypal.com/”>PayPal</a> or <a href=”http://www.wachovia.com/”>Wachovia</a>.
Just do as FOX says, and PAUSE. If you do this enough, you’ll find yourself checking to see where you are and where you are going on the internet. Not only will your computer be happier, you will feel more secure in your computer usage.

Note: I put all these links in this post to show you what your status bar will say when you run your mouse over them. All sites linked from this site are reputable. I would never subject any of my readers to malicious sites.

The Wonders of Firefox

No two web browsers are created equally. Internet Explorer, shipped with Microsoft’s Windows, is just the tip of the iceberg. There are many many web browsers out there, but Internet Explorer, or IE, is the most popular. Firefox, from The Mozilla Foundation, is an open-source* web browser that is completely customizable. If you haven’t checked it out yet, try it for a day. I’m sure you’ll love it.

Back in the old days of the internet there were two main web browsers, IE and Netscape. Netscape was purchased by AOL in the 1990’s, and AOL made parts of it open-source. The Mozilla Foundation was created and used the openly available source code to create Firefox. Since, Firefox has gained a small portion of the market because of it’s customizability and price**.

I use Firefox 95%*** of the time. While I’m surfing, I can see the weather, current & forecast & animated radar, the amount time I have left to work today, the latest tech news, whether a page is valid, who signed off on the security of the site I’m on, and a Google/Yahoo/Wikipedia search box. I see this information no matter what page I am on because I have various extensions, or Add ons, installed.

My extensions include:

  • Forecastfox Enhanced (larger radar loop than Forecastfox)
  • Web Developer’s Toolbar
  • WizzRSS
  • Firebug
  • Del.icio.us Buttons
  • Adblock Plus
  • HTML Validator
  • Server Spy

I have experimented with creating my own extensions as well, that’s the one that tells me how long I have left to work today.

Beyond Add ons, there are themes. A theme is just a styling of the browser itself. There are tons of these readily, and freely, available. There’s even a Walnut theme which paints the status bar, menu bar, and all the toolbars to look like Walnut wood, grains and all. I just use the plain jane theme that came with Firefox.

If you feel like IE isn’t working for you anymore, or you just want to try something different, then give Firefox a try! Download it at http://www.getfirefox.com/.

*Open source is just netspeak, or technical jargon, for a piece of software whose source code is made available to the public.

**All open source software is free.

***This would be 100% of the time if I didn’t care about the people who use IE.

Had your fun today?

Technology is meant to make life better. Some people will argue it’s to make life simpler, but anyone who owns a computer knows this not to be true. I spend about 30 minutes a day on YouTube just to laugh. That being said, enjoy this video I found earlier today.

This post is dedicated to my cat, Peaches.

Welcome!

Hi! My name is Barry and I used to run The Computer Guy in Augusta, GA. Sadly, I had to close my doors more than a year ago due to car trouble. Since, I have completed a computer programming degree at Augusta Tech and have a full time job in downtown Augusta. To all of my customers, I am sorry that I closed my doors. I have been thinking of reopening The Computer Guy, but that’s still up in the air.

That being said, I’ve decided to start a blog to help anyone with any computer needs. There are also forums, which aren’t setup yet, where you can post your computer question. I’m still trying to get everything up and running, so please be patient.

On this site, I will post a new blog entry every day, so check back often. I look forward to helping everyone!

Barry

PS: My first name is James, but my family calls me Barry. I will respond to both. Sorry for any confusion.