Thought and Freedom

Articles for those who think. By Terry Pearson

Archive for the ‘Tutorials’ Category

Terry Pearson's 7 Steps To Bittorrent Success

with 8 comments

Bittorrent (pronounced and sometimes spelled “Bit Torrent”) has the potential to completely change the way files are served on the internet. Bittorrent was created by genius programmer Bram Cohan. It allows large files, like open source software distributions, to be downloaded quickly from several “grassroots” file sharers.

JXTA Java P2P ProgrammingThis technology is closely related to Peer to Peer file sharing. Bittorrent differs from some file sharing programs in that it breaks up the files into several bite size pieces and allows users to partially download files from several sources.

One major problem with sharing large files over the internet is that many broadband web hosting companies significantly limit your upload speeds. This means that you may be able to download a file at 8mbps but only upload the file to your friend at 0.8mbps. Thats like saying you don’t have a speed limit, but the guy in front of you does (in the no passing zone of course).

This bottleneck is solved by allowing a downloader to solicit pieces of a file from several people who also have pieces of the file. Eventually the goal is to have the whole file, but in the mean time, it significantly increases your ability to download. You can now download from ten people who each upload at 0.8mbps. If you multiply that out, you are now maxing out your download speed. Not bad at all.

Bittorrent can be a little confusing, and may not be for the ungeeky at heart. But with a little background, it becomes much easier. So without further ado, I will give you Terry Pearson’s 7 steps to bittorrent success.

  1. Download a Bittorent Client. Bittorent downloads require a special software. Don’t worry, the best of these are free. I recommend Azureus. It is free of spyware, and very reliable.
  2. Install the client. This is pretty straight forward. You will need the latest version of the Java Runtime Environment which is provided at the link to Azureus found in number one.
  3. Determine a file that you want to download. For starters, go to http://distribution.openoffice.org/p2p/. You will answer three questions about your operating system and language. After answering those questions, you will begin to download the “.torrent” file. More than likely you will want to choose to “open” rather than save the file. By the way, this is for OpenOffice, an office suite similar to Microsoft Office, but with more features. Sun Microsystems, used to charge for it (under the name StarOffice) but now gives it away in hopes that people buy support packages for the software.
  4. Agree to Import Your Torrent. If you are using Azureus, this will be done automatically. It will pop up a temporary message in the bottom of your screen.
  5. Wait patiently, and do not shut down your client. Remember that your file is huge. More than likely, it will take a little time, but you will hopefully have a much better download than you would get from a file transfer from one computer. By the way, Bittorent is designed to help those who help others. If you disable sharing your pieces of the file, you are known as a leach. Leaches are often blocked, so you will actually download slower than otherwise expected.
  6. Explore your new software. If you are using Azureus, click on “My Library” and go to the “Advanced” tab. You will see a much more “Windows-ish” looking interface. The table will give the file size and status among other things. Some terms that you will come across include Peers, Seeds, and Trackers.
    • Peers - These are computers that you are currently either connected to, or attempting to connect to. Sometimes, Bittorent programs set a maximum number of connections. Therefore, you may have to wait in line for a part of a file.
    • Seeds – These are computers that contain the entire file. It is not mandatory that a torrent have a seed, but torrents with seeds are more likely to be completed since at least one member of your torrent has the complete file.
    • Tracker – This is a server that coordinates how the files will be downloaded. It keeps a record of which computers have certain pieces of the file, and then gets the file pieces to the right places in the most efficient manner.
  7. Practice good Bittorent Etiquette. In order to allow others to get completed files, at least one person needs to be sharing each part of the file. Remember that someone shared with you, so please share with them. This could involve keeping the files shared in your Bittorent client as long as possible. The upload rate will usually be slow, so don’t worry about it bogging down your bandwidth. Remember, you can download a lot faster than you can upload.

Written by Terry Pearson

May 9th, 2007 at 9:28 pm

Posted in Internet,Tutorials

Test your Java Skills

without comments

I am currently in a Java class at my university. This is a language that I think is just wonderful. Java (and  .NET languages) truly utilizes Object Orientated Concepts to the fullest.

When you are learning a language, it is sometimes difficult to test your skills. You certainly think you know a lot about the language, but how do you know that you are an expert? Possibly the best way, besides certification, is to take online tests on the language of your choice.

A great place to look for these online tests is on text book publisher websites. For example, my textbook entitled “Introduction to Java Programming” by Daniel Liang, has a website with source code and tests available to all. This tool makes it very easy to assess your current skill set, and helps identify areas in which you need to improve.

Written by Terry Pearson

April 4th, 2007 at 6:41 pm

Things to Know Before You Graduate – For Computer Science Majors

with 2 comments

As a computer science major, there are many things you should know before you graduate. To land a job, it is important that you have a broad base of knowledge when it comes to computer science. Below, I have compiled a list of some key things to know before you graduate.

By the way, these are mainly from questions that were asked during my interview with Avanade last week.

  • SQL Transaction
    • The combination of several SQL statements into one atomic group. It allows for an all or nothing approach.
  • SQL User Defined Functions
    • Functions that are run on the SQL server that are created by the user of the DBMS.
  • SQL View
    • A view appears like any database table, and can be operated on just like any table, but is actually a portion of a database table.
    • CREATE VIEW myview AS
    • SELECT name, age
    • FROM students
    • WHERE age = 5
  • Definition of Inner Join
    • A join of two tables that returns records for which there is a matching value in the field on which the tables are joined.
  • Definition of Outer Join
    • A table join in which rows from one table are included in the result set, even if they don’t contain values that match those in the other table.
  • Normalization
    • Decreases the amount of data
    • Decreases the load on the server and can increase performance
    • Going beyond 1NF can introduce logic errors when inserting/updating/deleting records
  • Acid Properties
    • In databases, ACID stands for Atomicity, Consistency, Isolation, and Durability. They are considered to be the key transaction processing features of a database management system, or DBMS. Without them, the integrity of the database cannot be guaranteed.
  • Linked Lists vs. Arrays
    • Duh! Just think inserts, deletes, and sorting and the complexity involved in these transactions
  • Interface
    • An interface is a description of a set of methods that conforming implementing classes must have.
    • Only non static methods and static final variables can be defined in the interface.
  • Abstract Classes
    • A class in which some of the functions are not implemented.
  • Characteristics of Object Orientated Programming
    • Inheritance
    • Encapsulation
    • Abstraction
    • Polymorphism
  • Access Modifiers
    • Public – Visible to all classes
    • Protected – Visible to the class they belong to and to any sub-classes
    • Private – Visible to the class they belong to
  • Software Development Methodologies
    • In the traditional waterfall methodology, first comes the analysis phase, then the design phase, followed by the implementation phase, with testing completing the process. The team that does each phase is different and there may be a management decision point at each phase transition. This methodology is called the waterfall methodology because each phase flows naturally into the next phase like water over a series of falls.
    • The spiral methodology fixes some of the problems introduced by the waterfall methodology. The spiral methodology still has the four phases. A little time is initially spent in each phase followed by several iterations over all four phases.
  • Sorting Algorithms
    • Bubble Sort
      • The array of values to be sorted is divided into two partitions: the partition of sorted values and that of unsorted values.
      • In each step of bubble sort, the smallest element found so far in the unsorted partition moves up, and it is appended to the end of the sorted partition.
      • The sorting proceeds until the elements in the unsorted partition are exhausted.
    • Selection Sort
      • The selection sort works by selecting the smallest unsorted item remaining in the list, and then swapping it with the item in the next position to be filled. The selection sort has a complexity of O(n2).
      • You have a Floor variable (which identifies the index of your first unsorted position in your array, and you have a minimum index variable that will point to whichever position is lowest so far. Once the remaining portion of the array is looked at, the floor variable and the minimum index variable are swapped.

Written by Terry Pearson

April 2nd, 2007 at 10:44 pm

Display a Double with two decimal places in Java

with 2 comments

I just spent the longest time trying to find the easiest way to make a double display two decimal places in Java.

Basically, I wanted to output money information, and it would look better if the money data says “$5.00″ instead of “$5.0″ as is sometimes the case. There are so many “solutions” to this, that it is difficult to wade through them all.
The best solution I encountered was relatively easy. You can find it in Sun’s Java forums.

import java.text.DecimalFormat;

double d = 8.9909879;

DecimalFormat dFormat = new DecimalFormat(0.00″);

String formattedString = dFormat.format(d));

The above code will format a string that has two decimal point precision. It will give the number 8.99 instead of 8.9909879.

Written by Terry Pearson

January 28th, 2007 at 1:48 am

Learn Java Swing

without comments

COBOL Programmers Swing with JavaIf you talk to a lot of programmers these days, you will hear an increased number of conversations about Java. With the open sourcing of parts of the actual language, and the strong support that Sun Microsystems has pledged to help an Open Source Java succeed, you can be sure that Java is likely to dominate the programming industry for the next several years.

For beginners, Java complicated to learn. However, beginners can greatly benefit from learning Java. By becoming familiar with the language, a new programmer will learn a great deal about object orientated programming.

As with any language, there are usually several good sources of learning that can be found on the internet. There are also several “not so great” sources. Sometimes it is hard for learners to determine the right place to start learning.

I would highly recommend Sun’s Java tutorial site located at http://java.sun.com/docs/books/tutorial/.

Another site that gives a basic introduction to the Java Swing Library (A graphical user interface library) can be found at http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/.

Written by Terry Pearson

January 6th, 2007 at 12:06 am

Web Project Planning for BethelFellowshipChurch.com

with one comment

I was recently asked to help build a website for my church in Minneota. I think that a church website is an excellent idea, and dove into the project as soon as the semester was over.

Having little information about what is needed for a project, can sometimes be difficult for the developer. He feels the need to do a good job on a project, but does not know which direction to take to meet the unsaid expectations.

So it is always good to plan then produce a prototype before diving into the real project. My planning began with a few simple ideas. I thought about the users of this website, what they would be able to use, and which tools would be possible to implement on a limited budget.

Because they probably could not spend large amounts of money on hosting, I figured I would have two options:

  1. Build an HTML based website that would be quick, easy, and cheap to implement, but would require knowledge of HTML to update.
  2. Use an open source LAMP based content management system. It would be slightly more difficult and time consuming to update, but it would be cheap and would not require the users to master HTML before modifying the pages.

I chose the second option. With the right content management system, the site could provide more than just basic information about Bethel Fellowship. It could provide tools to make the church better organized and provide a method for collaboration among members on various projects.

I looked at several content management systems (and used some experience from the past) to pick the perfect system. I looked for systems that had the modules or add-ons that I needed, and that looked like they had good templates for use. I also observed the learning curves for the average user.

I ultimately chose Xoops. To be honest, Drupal was a close second. It was a tough choice. If it had been my own site, Drupal would have been on the top of the list, but the interface in Drupal is difficult for new users to understand. So even though Xoops is less customizable, and contains less free add-ons, it met the needs of the organization (especially the easy to use environment), and I decided to go with it.

I built a prototype site on my own server, and provided a link to the people who made the decisions. We discussed through email, various changes, made updates, and then decided to move to the next step.

Next, I needed to find a hosting provider. Fortunately, I had done my homework when I setup my dad’s two sites, MikePearson.org and CriticalMove.info. I had found that 1and1.com provides reliable hosting for a really good price and therefore, was able to conclude quickly that this was still the best option.

Last night, I finally received the user name from 1and1, and began building the site. It went rather fast (since I had just built the site a few days earlier on my own server). A lot of time was simply uploading the files. Today, Bethel Fellowship’s site is up and running, and it looks pretty good. When I have some more time this week, I will be adding more to the site.

You can check out the progress at BethelFellowshipChurch.com.

Written by Terry Pearson

December 26th, 2006 at 3:08 pm

Learn SQL – The Art of Structured Query Language

without comments

If you are involved in web development, you will eventually find the need to learn SQL.

Also called Structured Query Language, SQL forms the basis for much of the more advanced web development. In order to make more interactive web sites, the information found one the web pages must be stored in databases. To read and write to these databases, you use a language called SQL.

A good resource for learning SQL is found in the W3 Schools tutorial section. After going through the entire lesson, you will feel much more confident in SQL. It is where I always recommend anyone starts there learning of Structured Query Language.

Written by Terry Pearson

December 9th, 2006 at 11:41 pm

Installing a Java Compiler

without comments

So you have a great looking program. Perhaps you typed out the source code for the hello world tutorial. Now, you need to transfer that source code into a computer language. You do that through a process called compiling. In our case, Java is compiled into Java Bytecode.

Sams Teach Yourself Java 2 in 21 Days (4th Edition) (Sams Teach Yourself)

Compiling a Java file produces a new file. If the old file is called HelloWorld.java, the compiled version of the file will be HelloWorld.class. This is how you can tell the difference between a compiled class and the original human readable format.

Where do I get a compiler?

Fortunately for potential Java programmers, the Java compiler (called the Java SDK) is free. The most generic solution is to go to the Sun Microsystems Java 2 SE download page and get the latest compiler version.

However, there are other options. One thing that I would recommend is to install an Integrated Development Environment, such as Netbeans. The Netbeans installer can also install the Java SDK. You will find a link to the Netbeans installer on the same Java SE download page. There is also a special “learning edition” of Netbeans that is called the BlueJ edition. It can be found here. It is specially designed to help students of java to learn the basics, and get familiar with an integrated development environment.

Written by Terry Pearson

September 26th, 2006 at 5:36 pm

Posted in Java,Tutorials

Improve the web with Nofollow Reciprocity.

Creative Commons License
Terry Pearson - The Blog by Terry Pearson
is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Stop SOPA