Feb 08

I ran across this pictures on The Samba and decided it was worthy of reposting. Never never never never jack your bus up like this. I bet I could go kick one of those supports and have the whole bus come crashing down. You should always use the proper jacks, jack stands, or hoists. If you absolutely cannot get access to them then please use something that is not quite so thin. Get a wider base.

638247

Feb 06

A friend of mine recently took a course on HTML web design and after completing her class she developed a website for Integrity Excavation and Rock Products. As a first site she did a great job. Go check it out.

Integrity Excavation and Rock Products

Feb 02

My networking professor handed out a group project to build a virtual token ring network and I thought I would share my findings here. Before you say anything, I know it is not a true token ring network, but it sorta acts like one which was more the goal of the project.

My group partner and I went through several different models, which included; building a virtual DHCP server and virtual cables, telling the program at run time who it's neighbor was, sending out a broadcast and having the virtual nodes organize themselves into a network, and a few others. We finally settled on pulling out a switch and creating a network of static IPs that we controlled. The program attempts to send to the next IP number from itself and if it cannot find it the token is sent to the first node. An unintended side effect is that we have the ability to add and remove machines at the highest IP number without breaking the ring. The requirement was only that it worked with three machines.

This code is not the cleanest, nor is it in any way awesome, and there are probably a ton of things I can take out of it to make it better, but it runs beautifully on the Dell Mini 10s running Ubuntu that I tested it on with a 5 port Netgear switch. Just make sure your network is in the range 192.168.0.1 and the machines go in sequential order (e.g. 192.168.0.1, 192.168.0.2, 192.168.0.3)

 
/*
 * Virtual Token Ring Network
 *
 * Networking II
 * Spring 2009-2010
 * Prof: Xueyi Wang
 * Group: Ben Lobaugh, Jake Bodenstab
 *
 * Project Description: Sorta creates a virtual token
 *      ring network simulation
 */
 
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string>
#include <string.h>
#include <strings.h>
#include <sstream>
#include <iostream>
 
using namespace std;
 
// Global Constants and Variables
int PORT = 55555, node, s_sockfd , s_clilen, s_n;
struct message{
        int sender;
        int receiver;
        string message;
};
struct token{
        int type; // 1 = empty token, 2 = token with data
        int valid;
        message msg;
        int checksum;
        int turn;
};
struct sockaddr_in s_serv_addr, s_cli_addr;
 
// Function Definitions
void getToken(char* token);
void sendToken(char* token);
bool messageExists();
void createServerSocket();
void error(string msg);
 
int main(int argc, char** argv) {
        char* token;
		string start_token;
 
		node = atoi(argv[1]);
		cout << "Node: " << node << endl << endl;
 
		createServerSocket();
 
		if(node == 1) {
			cout << "Start token? (y/n): ";
			cin >> start_token;
 
			if(start_token.compare("y") == 0) {
				cout << "\nInitializing Token\n";
				sendToken(token);
			}
		}
 
		cout << "**** Ctrl-C Terminates **** \n\n";
 
		while(1) {
			getToken(token);
 
			if(token[0] == 2) {
				// Token Contains a message
				if(token[2] == node) {
					// Message is from us. Erase it and change token type to 1
					token[2] = -1;
					token [3] = -1;
					token[4] = -1;
					token[0] = 1;
				} else if(token[3] == node) {
					// Message in token is for us. Display it
					cout << "--------------\n";
					cout << "From: " << token[2] << endl;
					//cout << token.msg.message << endl;
				}
			} else if(token[0] == 1) {
				// Token does not contain a message
				if(messageExists()) {
					// There is a message to send. Load message into token and change type
 
					 // Open file ./message.tok
					 // Read first line as the receiver
					 // Rest of file is message 
 
					token[0]  = 2;
				}
			} else {
				// This token is a type we do not know about
				// Don't worry about this token, just forward it
			}
			sleep(2);
			// Send token along it's merry way
			sendToken(token);
		}
 
       return (EXIT_SUCCESS);
}
 
void getToken(char* token) {
	int newsockfd;
	/*
	 * Create a server socket on PORT
	 * Listen on socket until message is received
	 * If message is of type token load it into token
	 * Close socket
	 * Return filled token
	 */
     listen(s_sockfd,5);
     s_clilen = sizeof(s_cli_addr);
     newsockfd = accept(s_sockfd,
                 (struct sockaddr *) &s_cli_addr,
                 (socklen_t*) &s_clilen);
     if (newsockfd < 0)
          error("ERROR on accept");
     bzero(token,256);
     s_n = read(newsockfd,token,255);
     if (s_n < 0) error("ERROR reading from socket");
 
	cout << "I've got the token\n";
}
 
void createServerSocket() {
 
	s_sockfd = socket(AF_INET, SOCK_STREAM, 0);
     if (s_sockfd < 0)
        error("ERROR opening socket");
 
	int on = 1;
	  if ( setsockopt ( s_sockfd, SOL_SOCKET, SO_REUSEADDR, ( const char* ) &on, sizeof ( on ) ) == -1 )
	    error("ERROR setting socket options");
 
     bzero((char *) &s_serv_addr, sizeof(s_serv_addr));
     s_serv_addr.sin_family = AF_INET;
     s_serv_addr.sin_addr.s_addr = INADDR_ANY;
     s_serv_addr.sin_port = htons(PORT);
 
     if (bind(s_sockfd, (struct sockaddr *) &s_serv_addr, sizeof(s_serv_addr)) < 0)
              error("ERROR on binding");
}
 
void sendToken(char* token) {
	int to;
	string ip = "192.168.0.";
 
	// Start Socket Vars
	int sockfd, n;
    struct sockaddr_in serv_addr;
    struct hostent *server;
	// End Socket Vars
 
	// Find the next node to send to
	to = node + 1;
	std::ostringstream sin;
	sin << to;
	std::string val = sin.str();
	ip.append(val);
 
	/*
	 * Create socket connection to next node
	 * Send token
	 * Close socket
	 */
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0)
        error("ERROR opening socket");
 
	try {
	    server = gethostbyname(ip.c_str());
	    if (server == NULL) {
	        error("ERROR, no such host\n");
	    }
 
	    bzero((char *) &serv_addr, sizeof(serv_addr));
	    serv_addr.sin_family = AF_INET;
	    bcopy((char *)server->h_addr,
	         (char *)&serv_addr.sin_addr.s_addr,
	         server->h_length);
	    serv_addr.sin_port = htons(PORT);
 
	    if (connect(sockfd, (struct sockaddr*) &serv_addr,sizeof(serv_addr)) < 0)
			throw 1;//("ERROR connecting");
 
		cout << "Token Sent To: 192.168.0." << to << endl << endl;
	} catch (int i)  {
		cout << "Could not contact " << ip << " sending to 192.168.0.1\n\n";
		server = gethostbyname("192.168.0.1");
	    if (server == NULL) {
	        error("ERROR, no such host\n");
	    }
 
	    bzero((char *) &serv_addr, sizeof(serv_addr));
	    serv_addr.sin_family = AF_INET;
	    bcopy((char *)server->h_addr,
	         (char *)&serv_addr.sin_addr.s_addr,
	         server->h_length);
	    serv_addr.sin_port = htons(PORT);
 
	    if (connect(sockfd, (struct sockaddr*) &serv_addr,sizeof(serv_addr)) < 0)
	        error("ERROR connecting");
 
	}
 
	bzero(token,256);
    n = write(sockfd,token,strlen(token));
    if (n < 0)
         error("ERROR writing to socket");
 
	close(sockfd);
	unlink(ip.c_str());
}
 
bool messageExists() {
	bool ret = false;
	return ret;
}
 
void error(string msg) {
    perror(msg.c_str());
    exit(0);
}
 
Jan 20

Nampa First had a great weekend youth retreat with the Senior Highers. Here are some pics for your enjoyment. Videos will come when I am not lazy.

(click to view the album)

img_3825

Jan 13

It has been a long time since I have put an update on my portfolio on here. I have not been as active trading because I lost my job and have not had any money to put into my account. I am happy to say my portfolio is still going strong and growing.

Retirement Portfolio

Jan 12

I went to see the Cirque Polynesia while I was in Maui and the drummer astounded me. I must have watched him for the first twenty minutes at least. He totally made the show. He reminded me of a cross between Kiss and Michael Jackson, leaning heavily towards the Joker. Check it out and see how much you like him too!



Nov 16

I started using jQuery last week and I am finding it to be a great library so far. It is very easy to interact with elements on the page in fun and creative ways.

As a sample, I have been working with the Northwest Nazarene University web team and they wanted to develop a simple wizard they can put on any page that will help prospective students find the degree they are interested in. I decided to tackle that task. At first I was looking at slide show sample, then one of the other developers showed me the beauty of .load(), which allows me to load into any arbitrary element the contents of any file or web address. After playing with .load() and the event handlers for an hour I figured out a way to implement what they wanted. It took me maybe 4 hours going from ground zero of no knowledge on the subject to implementing a working system complete with calls to a backend PHP file that gets the contents for the wizard from the database. jQuery is really neat, I highly encourage other web developers to check it out. A working sample may be found here or on NNU's website.

Here is the jQuery code I used. Try not to be too critical, I am positive there has to be a better way of doing this. I still am learning the vast amount of options available to me in jQuery.

 
<script type="text/javascript">
 
$(document).ready(function() {
	$('#programs').load('programs.php', {}, function() { // Load the degree options
           $('.choice').bind('click', function() { // Load the school in that degree
	        $('.choice').bind('click', function() { // Load the list of degrees
						$('#programs').load($(this).attr('href'), {}, function () {
							$('.choice').bind('click', function() {
								$('#programs').load($(this).attr('href'), {}, function () { // Load a degree
					                        });
							});
					});
				});			
		 });
	});
 });
</script>
 
Oct 15

I was practicing piano today and I suddenly had a possible idea for a song. I started messing around a bit and I did not want to forget, so I fired up Reason 4 and recorded some of my ideas. This is a loop that has a bunch of instruments thrown together all at once. Obviously it is highly unfinished. Hopefully I will have some time to flesh it out a bunch more and turn it into a real song. Take a listen

Old Timin

Sep 25

Chocolate Chip and Peanut [butter] Cookies

1/2 cup butter or margarine, softened
1/2 cup granulated sugar
1/4 cup brown sugar, packed
1 egg
1 teaspoon vanilla
1 cup all purpose flour
1/2 teaspoon salt
1/2 teaspoon baking soda
1 6 ounce package (1 cup) semisweet chocolate pieces
1 cup peanut [butter]

Preheat oven to 375 Degrees F

Cream butter or margarine and sugars; add egg, vanilla and beat until light and fluffy. Sift together flour, salt, and baking soda; stir into creamed mixture; blend well. Add chocolate pieces and peanut [butter] and stir by hand.

Drop from teaspoon about 2 inches apart on a greased (I don't grease because I use peanut butter not peanuts) cookie sheet. Bake in 375 F oven 12-14 minutes. Remove from sheet immediately.

Yield: 3 dozen Cookies.

Sep 25

Slice 4-5 potatoes in greased casserole. Salt and pepper to taste. Slice 1 onion over potatoes. Fry 1 pound hamburger and spread over potato mixture. Mix:

1 can cream of mushroom soup
1 can milk (soup can)

Pour over mixture. stir once. Bake 45-60 minutes or until potatoes are done. Sometime during the last 10 minutes of baking spread grated cheese on the top.