SEARCH W7R

Sunday, January 29, 2012

11 Notable Experiences Blogging Thus Far

I have been blogging for about six (6) months and I want to share my experiences with you so you can avoid or prepare for the early upsets that most bloggers run in to at one time or another. 
From My Own Experiences Blogging...

1. Large Posts reguardless of all the work I put into them receive less pageviews than those I create in under an hour and a half.


2. Money is Best Left Out of Your Blog for a While. Blogs with ads seldom get ad clicks because people do not like ads, thus refrain from clicking them.


3. Organization is a must! I wish I was and am more organized all of the time. People are online either to get info fast, communicate to others, or to entertain themselves.


4. Use Tags on all posts to ensure some structure and acuteness to your sites content.


5. Posts with Pictures usually have a better yield of pageviews.


6. You do not want to force people to your blog. Blog readers who read content they are not interested in are likely to give you false hope for increased pageviews or traffic. So, if you are going to advertise your site, make sure it targets the correct audience.


7. Compare and Contrast your blog to the best of your niche or topic.


8. Keep your head on straight. There are No Shortcuts in Success.


9. Make sure there is Contact Information present for your users/readers to use in case they have feedback (important for your blog) or questions.


10. Repairing Old Posts for the most part is transperent in effect. The Repairing of old posts will take time to translate into more traffic and readers.  


11. Listed Posts are often easier to understand (for the readers) thus blogs can be improved by having more posts that are listed (like this one! Irony.)

More W7R Blogging posts: 9 Traits Of A Successful Blogger
Thanks for visiting W7R, Brian.

What in the World Wide Web is a Gif?

w7r.blogspot.com

What is a GIF?

A Gif, pronounced "Jif," is a simple image format (as opposed to .img, .jpg, and .png) that only consists of 256 different colors. In the RGB (red-green-blue) color system there are 256^3 or 16,777,216 different colors.

So when comparing the the number of colors supported by gif files to image files that follow the RGB system, RGB color system has 65,536 x the amount of colors that gif images have. Gif images are dominant amoung simple web page images because they take up less space (less bytes of information to process and render). The smaller the file, the faster it will load, and for websites this is extremely important because people can lose interest in a website in the millisecond range.
If pictures are not present from the start people will think BORING. All gif files end with the extensions .gif so to search google strictly for gif images type file: .gif  into the search bar

Gif files are used for simple animations as well! Here are some cool examples:


Saturday, January 28, 2012

AOI Logic With Integrated Circuits (74LSXX)



Bunch of Integrated Circuits
  "AOI Logic" stands for And Or Inverter Logic. Invert is also referred to as a NOT gate because it outputs the opposite logical value of its input. In a NOT gate, when the input pin is connectied to +3V (logic high) then the output pin becomes attached to 0V (logic low). Resource Links, see bottom of post!



"So then, What is the 74 Series?" 
The 74 Series is a large set of Integrated Circuits (IC). Integration Circuits are space saving, fast, and pre-built mini circuits encapsulated in a bit of black plastic. ICs are also refered to as "chips".


Our Focus Today and Probably the Most Basic Of The 74 Series IC chips... 
The AND, OR, and NOT gated IC Chips (74xx08, 74xx32, 74xx04)


Reading Chips Can Be Difficult
The 74 Series chips have VERY confusing labels such as: "SN74HC04" or "MC74S02" + tons more...
   When reading the chips you need to look for where it says "74" and then skip to the next set of numbers on that same line where a second number will appear.

74xx08 is 4 AND gates in one chip (2 input : 1 output per gate)
74xx32 is 4 OR gates in one chip (2 input : 1 output per gate)
74xx04 is 6 NOT gates in one chip (1 input 1 output per gate)

All three, 74xx08, 74xx32, 74xx04 integrated circuits (IC) have 14 metal pins oriented into two parallel lines, 7 on both lines (2*7=14 of course!).


PIN LABELS FOR YA!
So, the 74 series chips like most integrated circuits (IC) do not have any pin labels; but this doesn't mean all hope is lost!
All 74 series chips have what is called a "data sheet" online in various locations for professional usage reference, but since we are not professionals I will explain the data sheet for the 74xx08, 74xx32, 74xx04 (AOI) chips.
74xx08
PIN1 = input1A;   PIN2 = input1B;   PIN3 = output1C;
  PIN4 = input2A;   PIN5 = input2B;   PIN6 = output2C;
 PIN7 = Ground (GND);   PIN10 = input3A;   PIN9 = input3B;
  PIN8 = output3C;   PIN13 = input4A;   PIN12 = input4B;
 PIN11 = output 4C;   PIN14 = Power (PWR) }

The Quad (4-gated) AND chip, 74xx08, has two pins for ground and power that must be hooked up properly for the chip to do its logic calculations. If you locate a dip or dot (or both even) on one side of the 74xx08 chip that is the "top" where the left-top pin is called pin 1 and the top-right pin is called pin 14. Pin 14 (top-right corner pin) is the POWER PIN. You need to supply
 the chip with from 4V to 9V of voltage through pin 14. *Same goes for the power set up for the 74xx32 and 74xx04 (inverter).

A 74LS08N chip (74xx08)

The logic function of an AND gate is to OUTPUT TRUE ONLY if BOTH input is a logic high (true/on).

AND Truth Table
A B C
0 0 1
1 0 1
0 1 0
0 0 1
AND gate chip (74xx08) Resources:
Commercial Sale: AND Gates (74xx08)

TAKE NOTE: PIN 14 IS POWER (TOP RIGHT + NEXT TO TOP INDICATOR DOT or DIP ON CHIP). This is true for the 74xx04 (inverter gates IC) and the 74xx32 (OR gates IC).



74xx32 (OR gate IC chip)

The Quad (4-gated) OR chip, 74xx32,
 has two pins for ground and power that must be hooked up properly for the chip to do its logic calculations just like the 74xx08 (AND gated IC). If you locate a dip or dot (or both even) on one side of the 74xx32 chip that is the "top" where the left-top pin is called pin 1 and the top-right pin is called pin 14. Pin 14 (top-right corner pin) is the POWER PIN. You need to supply the chip with from 4V to 9V of voltage through pin 14.  *Exact same power hook up as 74xx08 and 74xx04
74S32N chip
OR Truth Table
A B C
1 0 1
1 0 1
0 1 1
0 0 0


The logic function of an OR gate is that the OUTPUT of an OR gate will be TRUE, the logic high (1) if atleast one input is a logic high (1). The 1 represents a point in a circuit with positive voltage. The 0 represents a point in a circuit with negative voltage (GND).



The Hex Inverter (6 inverter gates) NOT chip, 74xx04, has two pins for ground and power that must be hooked up properly for the chip to do its logic calculations just like the 74xx08 (AND gated IC) and the 74xx32 (OR gated IC chip). If you locate a dip or dot (or both even) on one side of the 74xx04 chip that is the "top" where the left-top pin is called pin 1 and the top-right pin is called pin 14. Pin 14 (top-right corner pin) is the POWER PIN. You need to supply the chip with from 4V to 9V of voltage through pin 14.  *Exact same power hook up as 74xx08 and 74xx32


Sadly, because there are 6 gates on the hex (6) NOT gated IC with the same number of pins (14) there is a different layout. It goes as follow. Counting counter-clockwise (anti-clockwise) starting with pin 1 and ending with pin 7 (GND): PIN1=input PIN2=output, PIN3=input PIN4=output, PIN5=input PIN6=output. PIN7 is Ground (GND). 
Do you see the pattern, yet?
 74xx04 only*
- Current pin:  Input 
- Next pin:  Output 
- Then:  Repeat unless the next pin number is divisible by 7 (GND and PWR pins)
Inverter Truth Table
A B
1 0
0 1

THANKS FOR STOPPING BY AT W7R, YOUR DOOR TO TECHNOLOGY. IF YOU ENJOYED THE POST FEEL FREE TO ADD W7R TO YOUR FAVORITES OR FOLLOW W7R. MORE TO COME. -Brian R. H.

AND GATE CHIP (74xx08):

OR GATE CHIP (74xx32):

INVERTER CHIP (74xx04):




Friday, January 27, 2012

9 Traits of a Successful Blogger

Blogging is not a piece the piece of cake it should be. It takes thought, time, energy, and interest. Your blogging experiences will be positive as long as you are positive. Give it your all, and listen to your viewers.


  1. Passion

    To blog in the big leagues you need to have passion about what you are writing and posting about! Write about what you enjoy! If you are experienced or good at it then that's even better! Be passionate.

  2. Patience

    Patience is a virtue. It truly is. You cannot expect a blog to be successful be worthy of 100 pageviews per day in one week.

  3. Dynamic Mindset

    Time is never still, and nor should your blog be. If you have ever been to a blog that was not updated for over a year? Most of the time it is a total turn off to be on a blog post that hasn't been improved or updated in a year plus. Keep on your toes and listen to all the complaints on compliments you receive about your blog.

  4. Easy On The Eyes

    If your blog is difficult to read or look at, then the only viewers you will acquire will be in desperation for the answer contained on your page. And with all the webpages on the web today, chances are that there is an easier to read version of your post one google search away.

  5. Friendly

    Blogs are meant to provide a service to people interested in the topics you cover. You want them to feel safe, comfortable, and happy when they read your blog.

  6. Unbiased

    You can have two times as many viewers if you can put aside your arguments and opinions and create a balance. This is not true for biased topics like politics: there are topics that demand your bias.

  7. Analytic

    You are aware of how your blog is doing statistically, and can recognize good and bad trends to learn from.
  8. Energetic

    Energy is what gets us up in the morning (metaphorically) and energy is what brings people to search the web. When I have no energy even the internet can be a arduous and/or tedious task. Keep your energy high and optimistic to ensure the user that you are giving them your all.
  9. Giving

    Share your resources, experience, and blogs in a liberal manner. If you have 10 ads on every page of your site, then you are not as helpful as you may think. Share with your readers.

Thursday, January 26, 2012

Simple Google Search Trick!


 I don't like to ruin surprises. So, instead of including a picture or description, I will leave out any details that could spoil the experience for you! I promise you are not going to hurt your computer in any way from following the provided mini-tutorial below.



Google Loco & Others
1. Visit Google home page.
2. Type "google loco" into the search box (do not include the quotation marks)
3. Then click where it says 'I am feeling Lucky!' (you may have to scroll over the search box to find 'I am feeling Lucky!')

Other keywords like "google loco"
"google l337"      "google linux"
"google gothic"      "google blackout"
"google fishtank"      "google your name"



I encourage you to try your own "google <anything>" to see what results you get and don't forget to show your friends and family!

Wednesday, January 25, 2012

Doesn't Everyone Knows Modulus Division? Yeah, Right!

Modulus Division Introduction

   Have you ever heard or seen modular division before? Modulus division often involves the % symbol as the operator just like + for addition, - for subtractions, * for multiplication, and / for division. It is a lot easier than long division because normally it is used in simple applications like figuring out if a number is even or odd. If I asked a programmer how to determine if an integer (-9,-8...0,1,2...9,10) was even he would answer "number percent sign 2 is equal to 0" or sometimes "use modular division". Modulus Division + Common Operation Calculator
   

Definition of "Modulus Division"
Many of the definitions on the internet for Modulus Division seem hellishly unreasonable, so let me put it in simple terms.
In simple terms, modulus division is the process of dividing one number by another (division) only to find the remainder that is left over. The number of times the number goes into the other is thrown away (hypothetically). All modulus division does is return the remainder.



Common Mathematical Examples
2 % 6 = 2
6 is bigger than 2 to start with so the remaining integer of the dividend is 2.

6 % 3 = 0
6 / 3 = 2 with a remainder of 0.

5 % 2 = 1
5/2 is 2.5 which is not an integer, so, you need to find the highest number that does fit into 5 that is a multiple of 2 (hint: it rhymes with s'more). Four and... 5 - 4 = 1.

16 % 16 = 0
16 goes into 16 one time only and has a remainder of 0.

1000 % 3 = 1
999 is a multiple of 3 that is less than the dividend, 1000. Thus, 1000 - 999 = 1.


How to do Modulus Division
An example of long division.
16 % 15 = 1
To solve a modulus division problem, you need to know the 3 key terminologies that go along with regular division: the quotient, dividend, and divisor. So, when prompted with a modulus division question you need to go back to the long division days where the first thing you do is think of the largest multiple of the divisor that is smaller than the dividend and then subtract that multiple times the divisor to find the remainder. If the quotient is greater than your divisor, then you did not use the highest integer for your multiple of the divisor.



Importance Of Modulus Division
In computer programming it can be used to distinguish whether an array or list of variables is of an appropriate size for a system. An example of that is if a system could only interpret bytes as arrays of 8 bits, the system could use modulus division to be sure no sets of the array would be broken into a piece of less than 8 pieces. {A byte is a unit of data storage used in digital systems and computers with 8 individual bits (binary digits)}.

Another example in computer science is to determine whether a number is even, odd, or even prime. The prime number algorithm takes a bit more thought than the even and odd number algorithm, so I will just show an example of an even number algorithm in the following section titled "Example Code Snippets."

Example Code Snippets
[in Java] 
//Even number method
public void getEven(int num){
if(num%2==0){
return true;
} else {
return false;
}

More Resources

Tuesday, January 24, 2012

Run Javascript Code through the URL Bar

/*Below is the format for the Javascript insertion*/

javascript: /*JAVASCRIPT CODE HERE*/ void(0);


Directions

  1. Type your Javascript code into a text document
  2. Open up any web browser.
  3. Go to any website.
  4. Replace the URL for the site with javascript:
  5. Paste your code at the end of javascript:
  6. Finally, add a space followed by void(0); to the end of the URL
  7. Hit [Enter] or click "Go!" to run the script

Example #1: A Name Prompt

A simple prompt for your name and then it outputs HI to you with the name you entered.

javascript:
 var name= prompt("What is your name?");
 alert("HI, "+name); void(0);


Example #2: Edit Any Webpage

This second one can allow you to edit webpages like a Word document (only for you, though). You can take pictures (PrntScr) to show your friends what you "saw" written on a website.

javascript: 
document.body.contentEditable='true';
document.designMode='on'; void 0;

Monday, January 23, 2012

Free Type-To-Learn Typing Lessons Online!

Type to learn is a classic program that is used in schools for kids to learn how to type formally; however, the lessons are usually not very helpful due to time constraints and the fact that the kids have already began their typing habits.

Luckily, there is a free and extensive type to learn like website online for free: Typing Web (Free Typing Lessons and Games)

Why people use Typing Web
   -FUN: You can see how fast you can type in different situations.
   -RECORDS: See how close you can get to the typing word record.
   -LEARN
   -INCREASE SPEED
   -SAVE TIME
   -TEST YOUR TYPING ABILITY

DVORAK keyboard is superior to the QWERTY standard?
117 Word Per Minute! (Dvorak keyboard)





A little extra motivation for your speed demon typing skills on the rise: 
Hands Free Typing Record Set

Saturday, January 21, 2012

Java GUI Tutorial 3 - Layouts and Layout Managers

In GUI Tutorial Part 2, we learned about a few commands we can use with JPanel objects. Essentially this post will be an expansion of your knowledge of JPanel components such as the button you created in the previous tutorial. (Go to the first tutorial post: GUI Tutorial Part 1)

Everything starts with a problem:

If I create a JPanel and a JFrame and add five JButtons to the JPanel (which is held in the JFrame), where would they be placed? The easiest way to answer this question is to try it out. Feel free to copy and paste my code. Highlight the java code, press Ctrl + C, select a text area where you can paste the code, press Ctrl + V.
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class ButtonGUI {
    public static void main(String[] args) {
        //create frame and panel to hold buttons. The frame and panel are our window
        JPanel panel = new JPanel();
        JFrame frame = new JFrame("Button GUI");

        //An array of JButtons limited to only 5 open slots
        JButton[] buttonList = new JButton[5];

        frame.setSize(500,500);

        //loop num [0, 4]
        for(int num=0;num<5;num++)
        {

            //creates a button labeled num and adds it to our JPanel, panel 
            buttonList[num]= new JButton("Button #"+(num+1));
            panel.add(buttonList[num]);
            buttonList[num].setVisible(true);
        }
        frame.add(panel);
        panel.setVisible(true);
        frame.setVisible(true);

    }
}

If you haven't already, please run the program (code is above) and view the location of the five JButtons. Resize the window of the program to see how the buttons positions change.
Minimized window had to reposition buttons vertically in 2 columns



Moderate space crunch for the buttons, horizontally. Notice each row of buttons are centered.
A large amount of horizontal space allows the buttons to be in one row.

There is an element of uncertainty to where the components (our buttons) will be placed on the JPanel. We need some way of organizing components of a JPanel in a predictable manner. For this, we have LayoutManagers, which act exactly like how their name implies: they manage the panels layout. The layout managers are helpful because you can avoid coding with absolute points (numerical locations) on the computer monitor more than one time!

For this tutorial I will introduce one of the easiest, but my least favorite LayoutManager provided by Java, the BorderLayout. The BorderLayout divides your Window into five parts, north, south, east, west, and center. 

My example code that builds off of the previous example code
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class ButtonGUI2 {
    public static void main(String[] args) {
        //create frame and panel. The frame and panel are the window
        JPanel panel = new JPanel();
        JFrame frame = new JFrame("Button GUI");

        panel.setLayout(new BorderLayout());
        //An array of JButtons limited to only 5 open slots
        // this array (list) cotains absolutely no buttons until we have instantized 
        JButton[] buttonList = new JButton[5];

        //Set the size of the JFrame, frame.
        frame.setSize(500,500);

        //loop goes through num integer values [0, 4]: (0,1,2,3,4)
        for(int num=0;numl&t;5;num++)
        {
            //creates a button labeled num and adds it to our JPanel, panel 
            buttonList[num]= new JButton("Button #"+(num+1));
            buttonList[num].setVisible(true);
        }

        //add each button to the panel with a direction field supplied by the BorderLayout class.
        panel.add(buttonList[0], BorderLayout.NORTH);
        panel.add(buttonList[1], BorderLayout.EAST);
        panel.add(buttonList[2], BorderLayout.SOUTH);
        panel.add(buttonList[3], BorderLayout.WEST);
        panel.add(buttonList[4], BorderLayout.CENTER);

        //Add the JPanel, panel,  to the JFrame, frame.
        frame.add(panel);

        //Make sure the window is visible.
        frame.setVisible(true);
    }
}

BorderLayout Results!

Very spacious. Button #1 and Button #2 are quite short relative to Button #3,4, and 5. A crunch horizontally. The BorderLayout allows the button in the center to be "pushed behind the others"
If I was going to use the BorderLayout, I would apply an invisible border to contain each button closer in size. This would also, make the background of the panel visible. How To Use Borders In Java is a good reference for Swing related problems, questions, or demos.

Some Other Layouts

  1. AbsoluteLayout
  2. -BoxLayout
  3. CardLayout
  4. FlowLayout
  5. GridLayout
  6. GridBagLayout
  7. GroupLayout
  8. SpringLayout
In GUI Tutorial 4 we will try out one of the other layouts listed above.

Friday, January 20, 2012

Who Knew Random Took So Much Thought

If I asked you to give me a random number within 1 to 100 from the top of your head what would you pick?
Would your pick be completely random? If you kept asking yourself for random numbers between 1 to 100 chances are you will repeat numbers several times before even reaching your 50th "random" number. If our brain is not able to respond randomly, do you think randomness exists in nature at all? 


Surprisingly, true randomness is arbitrary (made up) just as much as numbers are themselves. Randomness is a way of describing something that is "completely" unpredictable. Sadly, nothing can be completely unpredictable, or perfectly just, because in nature we experience patterns, sometimes clear ones like the stems of plants and other times obscure ones like the orientation of the mushrooms relative to one another after a light rainfall. The patterns that govern our world are infinitely big, so there is no saying that any human will live to see the completion of some patterns that exist as a function of time.

Why would I or you, a tech enthusiast, a student, or a professional care about the randomness in nature? It is because successful programs, algorithms, and other functions that simulate the real world need to be able to be as close as possible to our theoretical values that have been proven time and time again. Probability for one, is extremely important to the fields of computer science, math, and engineering (of course there are many more fields too) because the products of technology solve problems based on theoretical representation of real life variables.

So, the reason I have been indulging in the thought of randomness is mainly because I have been programming my own version on Tetris in Java code and have realized the inaccuracy in the random function of the Math class. Basically, programming languages cannot generate random numbers without following some pattern or algorithm which means that they are slightly predictable and unusual. By unusual I mean that I may have five blue tetrominos (one of seven of the tetris pieces) in a row, "randomly." The chances of that occuring are (1/7)^(5) * 100 %. I did the math for you: 0.0001214265% chance of that occurring. As a stern programming I wanted to fix this ASAP, well lets say ASAP did not come as soon as I wanted. Turns out the "Math.random()" command generates a psuedo-random number which has poor acurracy as far as random goes. Math.random() would be sufficient for many programs, but in tetris if the pieces are being distributed unevenly, then each game will be more or less fair depending on how the beginning value the psuedo-random algorithm uses.

I wanted to have a little experiment or two, so I did. Here is my code for checking how the random values have been. And don't worry, I'll do my best to explain each step in lines of comments (comments follow double forward slashes //). And the class this was used in I called GameStats. GameStats has a


public static void printPieceStats() {
        int total = pieces[0]+pieces[1]+pieces[2]+pieces[3]+pieces[4]+pieces[5]+pieces[6];

        System.out.println("\nL_PIECE (blue): "+pieces[0]+"   |  Percent: "+((pieces[0])/(double)total)*100+"%");
        System.out.println("J_PIECE (orange): "+pieces[1]+"   |  Percent: "+((pieces[1])/(double)total)*100+"%");
        System.out.println("I_PIECE (teal): "+ pieces[2]+"   |  Percent: "+((pieces[2])/(double)total)*100+"%");
        System.out.println("Z_PIECE (red): "+ pieces[3]+"   |  Percent: "+((pieces[3])/(double)total)*100+"%");
        System.out.println("S_PIECE (green): "+pieces[4]+"   |  Percent: "+((pieces[4])/(double)total)*100+"%");
        System.out.println("O_PIECE (yellow): "+ pieces[5]+"   |  Percent: "+((pieces[5])/(double)total)*100+"%");
        System.out.println("T_PIECE (purple): "+pieces[6]+"   |  Percent: "+((pieces[6])/(double)total)*100+"%");

        System.out.println(total);
        //ideally each piece would be dropped 1/7 of the time.
        double ideal = 1.0/7.0*10.0;

        double[] dubs = new double[7];
        int place=0;
        for(int num: pieces) {
            dubs[ place ]= (num/(double)total)*10.0;
            place++;
        }

        //find their percent error.
        //store the percent error
        //use absolute value to stabilize signs.
        //average all of the percent errors together
        double [] percentErrors = new double[7];
        place=0;
        double errorTotal=0;

        for(double d: dubs) {
            double dub = Math.abs((d-ideal)/(ideal)*100);
            percentErrors[place]=dub;
            errorTotal+=dub;
            place++;
        }

        //errorTotal is the sum of % error of each piece which is divided by 7 to yield the average percent error.
        System.out.println(errorTotal/7);
    }

I use the value that is printed out to determine how close my program is to being completely random. I coded this method and you are free to copy and paste the code. The same method could be adapted for all kinds of applications, just follow its steps that are commented in the code.

Java's Math.random Explained!

The command, Math.random() Explained!

Math.random is an important feature of the Java programming language. It generates psuedo-random numbers which in simple terms are approximated random values.

For most applications written in Java, Math.random is upredictable enough to be considered random.

So what does the command do exactly?
Math.random() creates a value from between 0 and 1; a fraction, essentially.

See it for Yourself!
Copy and paste the following code into a main method of any java class. 

/**This will be a double value between 0 and 1. 
* The value discludes 0 and 1,
* so it is non-inclusive or exclusive
*/

//Prints a random number (0 to 1) to the console.
System.out.println(Math.random());

The Realistic Application Of Math.random()
Programmers can get integer (-1,0,2,3,4,5, ect...) values randomly by manipulating the double (decimal/fraction) value returned by Math.random().

int lowNumber = 1;
int highNumber = 6;

//This code is actually an algorithm for getting random integers by means of Math.random()!
int faceOfDice = (int)((Math.random() * 6) + 1);

//Print out the result
System.out.println("Face of die: "+faceOfDie);

Thursday, January 19, 2012

Java GUI Tutorial 2 - Basic JPanel Attributes

JPanel methods can be used to access, or alter the visual content of the GUI.
GUI, for refreshers means Graphical User Interface and is often pronounced as "Gooey." Same sound as the name Stewie, but with a G instead of an 'S' and 'T.' The GUI ("gooey") is an important piece of any program because it allows the user to understand what the program is doing, in a visual manner! Could you imagine trying to play angry birds if all you heard was a voice explaining what is happening, or if a program  would not print an error but instead say "error." Visually we can interact with programs with ease (most of the time).
   ... long description...
In short, Graphical user interfaces need to be user-friendly, simple, and effective for your programs to succeed!
Now let's decorate the "GUI" (really just a window) we created in the last tutorial using Java code.

If you missed the previous tutorial click here (Tutorial 1). Let's start where we last ended:

import javax.swing.JFrame;
import javax.swing.JPanel;
/**
* W7R.blogspot.com 
* GUI Tutorial Part 1: JFrame and JPanel
*/
 class Example{
   public static void main(String[] args){
      //Create a JFrame named frame1 with a title of "Frame Name" 200 by 200 pixels
     JFrame frame1 = new JFrame("Frame Name");
     frame1.setSize(200,200);
      //Create a JPanel names panel1 with no parameters
     JPanel panel1 = new JPanel();
     frame1.add(panel1);
     frame1.show();
   }
}


Our example class from the previous tutorial is so basic that we cannot really call it a GUI yet. This will change! Let's begin by giving our JPanel, panel1 a background color. This requires the setColor method. I will set my JPanel to be blue, but I will include a comment with the other color choices. I will also change the name of the frame (the window border that holds the JPanel) to be "W7R Java GUI Tutorial 2."

**NOTE: To use the Color class you must import java.awt.Color You can type this above the other imports or copy it from here.
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
 * W7R.blogspot.com 
 * GUI Tutorial Part 2: JPanel Appearance
 */
class Example{
    public static void main(String[] args){
        //Create a JFrame and JPanel
        JFrame frame1 = new JFrame("W7R Java GUI Tutorial 2");
        JPanel panel1 = new JPanel();
        //set size of JFrame to be 200 x 200 pixels
        frame1.setSize(200,200);
        //Set background color of JPanel (panel1) to be blue.
        //Other color types: Color.red, Color.orange, Color.yellow, 
        //Color.green, Color.blue, Color.purple, Color.white, Color.black, Color.gray
        panel1.setBackground(Color.blue);
        //Add panel1 to our JFrame (frame1)
        frame1.add(panel1);
        //Make frame1 visible to user
        frame1.setVisible(true);
    }
}
Now, it is safe to say that we have a more appealing window, but not necessarily a GUI. So, lets add a button to it! This will add functionality to our program. For starters the button will just be pushable; no action yet. Later we will do more complex things with the JButton.
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
 * W7R.blogspot.com 
 * GUI Tutorial Part 2: JPanel Basics
 */
class Example {
    public static void main(String[] args){
        //Create a JFrame and JPanel
        JFrame frame1 = new JFrame("W7R Java GUI Tutorial 2");
        JPanel panel1 = new JPanel();
        //Create JButton names button1 with the label "Push me!"
        JButton button1 = new JButton("Push me!");
        //button1 will be pushable, but will not do anything, yet.
        //this will allow the button to be controlled with the space bar too
        button1.setFocusable(true);
        //set size of JFrame to be 200 x 200 pixels
        frame1.setSize(200,200);
        //Set background color of JPanel (panel1) to be blue.
        //Other color types: Color.red, Color.orange, Color.yellow, 
        //Color.green, Color.blue, Color.purple, Color.white, Color.black, Color.gray
        panel1.setBackground(Color.blue);
        //add button to JPanel
        panel1.add(button1);
        //Add panel1 to our JFrame (frame1)
        frame1.add(panel1);
        //Make frame1 visible to user
        frame1.setVisible(true);
    }
}


Wednesday, January 18, 2012

SOPA Vs World

This is the time to make a stand for your right to privacy. The internet is home to more data than a whole country of people can keep in their lives. I want to show the reactions the world has had to the two pieces of legislation on their way to be passed. THE NEW BILL WOULD ALLOW THE AMERICAN GOVERNMENT TO STOP PEOPLE FROM USING THE INTERNET OR CERTAIN SITES. THAT IS NOT RIGHT. EVEN IF YOU ARE NOT AMERICAN, YOU ARE AT RISK TOO.

This bill can take down your favorite sites! Even blogs or forums that are "accused" of copyright infringement.



Refine Google Search with URL Endings

One of many ways to increase search accuracy and to save you valuable time is the "site:" keyword (with Google Search).  The keyword is interpreted by the search engine to restrict results of any other ending other than the one following the "site:" keyword. If you know you are looking for a site regarding educational material you may want to use "site: " with ".edu" to focus your results to websites ending in edu.

  Specify Site Endings with "site:" [URL ending]

By typing site: .edu you are only searching sites with the ending .edu. Other common endings to try with the "site:" keyword are
 ~ .com ~ .net ~ .gov ~ .org


Examples!
A.   I will search for computer tips strictly from .net sites.
I type " computer tips site: .net" into the search box and press [Enter].

B.   I will search for biology help only from educational sites
I type " biology help site: .edu" into the search box and press [Enter].


If you enjoyed this quick tutorial, +1 or follow for many more! 
Thanks, Brian.

Monday, January 16, 2012

Troll Meme Compilation!

I searched the internet to find a handful of the funnier troll face/meme pictures. Enjoy!

Golbat pokemon troll.

Old school trollin'

Father troll at its finest.


Some are trickier than others.




A trolling success

Environmental Troll

Troll Math 101. Yes please.

Troll proves we that are we all lesbian.

Math trolling fail.




Fail troll


Religious Trolling




Animated troll face nyan cat = WIN




Troll face in real pictures


Some don't make much sense.






Rediculous Troll Innovations


The classic troll face






Sunday, January 15, 2012

Java vs Javascript: Common Misconception


There is a BIG difference!

 Java and Javascript are two totally different *programming languages. Technically Javascript is a scripting language which is a more specialized language than the object oriented design (OOD or OOP) programming language, Java. First misconception cleared!: Java and Javascript are unrelated. Just like the words, "milk" and "milkweed". Milk is a drink (moooooo), and milkweed is a plant (Monarch butterflies lay there eggs on milkweeds).

 Sun Microsystems did not create Java and Javascript. Sun Microsystems only developed Java; not Javscript. The Javascript scripting language was developed by Netscape with a syntax (format) similar to that of Sun-Microsystems' Java. Now, Java is owned by Oracle.

 Javascript is widely used on the internet to create dynamic, interactive, and stronger content than HTML can support alone. When compared to Java, Javascript has more power and dynamism, but less performance.

An example of Java code declaration of an integer:
int counter = 0;

An example of Javascript code declaration of an integer:
var counter = 0;

  "var" which stands for variable can be used to describe an integer, because Javascript will determine the type of variable for you. In Java you must specify the type of variable with the code "int". In Javascript if I assigned a variable to be an integer (var num = 1;) then I can change the variable to a String.

Javscript Code:
num = "subscribe to W7R if this post helped";


 Now, the variable, num is refering (or is equal to) a String, so it is a String data type. This ability makes Javascript more dynamic than Java because if an integer was to be assigned to be a string in Java your program would crash.

To learn more check out the following links!

Saturday, January 14, 2012

Java GUI Tutorial 1 - JFrame and JPanel

GUI = "Graphical User Interface"


JFrame and JPanel are simply two files included in Java to allow you to create displayable content.

Let's start with an understanding of the relationship between the JPanel and JFrame. (NEWCOMERS, DO NOT SKIP THIS).

First off, JFrames contain JPanels! This is important because if you tried to add an instance of JFrame to one of JPanel your program would not function as desired. Think of JFrame as a stretchable picture frame that can hold an as much visible content (JPanels, JButtons, JLabels,...) or even no visual elements what-so-ever.
The JPanel is like a canvas. It rests inside the JFrame and carries out its JPanel functions independently (mostly) of the JFrame. A JPanel without a JFrame (or other type of frame) would be invisible, which defeats the point of an application.

Example Code #1


import javax.swing.JFrame;
import javax.swing.JPanel;
/**
* W7R.blogspot.com 
* GUI Tutorial Part 1: JFrame and JPanel
* Example Code #1
*
*/
 class Example {
   public static void main(String[] args){

      //Create a JFrame named frame1 with a title of "Frame Name"
     JFrame frame1 = new JFrame("Frame Name");

      //Create a JPanel names panel1 with no parameters
     JPanel panel1 = new JPanel();
   }
}
In the example code (#1), in the main method, I created a JFrame, "frame1" and a Jpanel, "panel1" Now you have two variables, 1 JPanel and 1 JFrame. We need to add the JPanel into the JFrame with a method in the JFrame class called "add." To make the window visible it will also be necessary to utilize the "show" method.
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
* W7R.blogspot.com 
* GUI Tutorial Part 1: JFrame and JPanel
* Example Code #2
*
*/
 class Example{
   public static void main(String[] args){

      //Create a JFrame named frame1 with a title of "Frame Name" and 
      //set our JFrame to be 200 pixels wide and 200 pixels high.
     JFrame frame1 = new JFrame("Frame Name");
     frame1.setSize(200,200);
//Create a JPanel names panel1 with no parameters
     JPanel panel1 = new JPanel();
   
     frame1.add(panel1);
      
     frame1.show();
   }
}

In the example code (#2) We put the frame and panel together and display it.
You will notice that the window is incredibly small: this is because we haven't given it content to hold yet!




That is all for now, but I am eager to continue this subject in GUI Tutorial Part 2, but just to keep you on your toes: All of the JPanel Methods.

For example, you can play around with the setBackground method

panel1.setBackground(Color.BLUE);