Saturday, December 25, 2010

Structure and Interpretation of Computer Programs


Have started watching the MIT lecture series: Structure & Interpretation of Computer Programs


This should tie in nicely with my desire to learn LISP.

Friday, December 10, 2010

Sorting and Searching Algorithms and Project Euler


I've some extra time recently (well, not really), so I've decided to increase my understanding of sorting and searching algorithms.


The project hosting site above is where I'll be doing my work.

I'm also using this to get familiar with Java, and in particular: polymorphism, interfaces, exceptions, encapsulation, inheritance, and modularization.

I've also started doing some problems from the Project Euler site, an algorithm problem website. Here's some of my solutions:

Wednesday, December 8, 2010

33. Decathlon Design 3

This is the final phase of our solar decathlon home management system mockup for the semester. We've been tasked with taking our Balsamiq mockups and converting it to an HTML-Wicket Framework model.




What I learned from this:
I learned a lot about Wicket, and got some very helpful hints on web design as well. I also can see the advantages of a framework like Wicket; it allows the developer to bundle everything into a neat little archive file that can be run from any computer. And in the webpage sector, this involves bundling a webserver (we used Jetty) so that any prospective client can view dynamic web content as long as they have the Java JVM installed. This avoids the difficulty of having to set up a web server or the need to have internet access in order to view a dynamic web page.

What we did well:
I've been lucky enough to be part of a group that has two exceptional web designers and programmers, which makes it incredibly easy and efficient to get things accomplished. I thought that we did a good job on focusing on the development of a template. This really allowed us to push forward quickly with the knowledge that the framework that we were working on was sound and well-developed.

Some Difficulties Encountered:
There was a lot of time spent just figuring out how to get Wicket to do what we wanted to in the HTML markup. There was also some Javascript that we used for some of the interactive portions of the system, and importing different libraries and getting them to sync with the CSS files was challenging to say the least.

What I wish we had done differently:
I would've liked to have created my own CSS file for custom classes. I had to add a few CSS classes and during one instance, I updated the CSS and found that another team member had committed the same CSS file prior to me, resulting in a conflict.

Other than that, we had pretty good communication and met a number of times in-person as well as over the phone to ensure everyone was on the same page.

How did we satisfy the three prime directives?
The three prime directives of open source software engineering are:
  1. The system successfully accomplishes a useful task.
  2. An external user can successfully install and use the system.
  3. An external developer can successfully understand and enhance the system
Directive 1:
This system provides home users with a portal that allows them to view the current status of the major systems within the home. It also allows the user to change settings such as temperature, lighting, and security to name a few.

Directive 2:
Due to the use of the Ant build system, installing and running the embedded jetty server takes a single command: java -jar filename.jar

Directive 3:
Developers can edit the server-side source code via eclipse (distribution file has been included in downloads section).

Monday, December 6, 2010

LISP and Finding an Interpreter/Compiler

After hearing of the 'light switch' effect and nirvana that LISP brings about, and reading the following article:


I've decided to start learning LISP during Christmas break. I had about a 3-week crash course on it during my Computer Programming Concepts class, but I didn't really think much more of it other than 'okay that was cool, but I'll never use this again.'



The Search for An Interpreter/IDE

I started by going through a couple of the available LISP interpreters: GNU CLISP, Ufasoft LISP, and LispWorks.

I'd used LispWorks before but decided that I ought to try some other IDE to get a sense for what's out there.

After trying to install Ufasoft, I found that a Microsoft Visual Studio component needed to be installed first. Cancel -- I wanted something that could work on both my MacBook and Windows machines. GNU CLISP installed fine, but this gave a command-line only interface and a quick look through things did not uncover any extensive help information.

So back to LispWorks. Here we go!






Saturday, December 4, 2010

Network to Host Long Long

Since I'm applying for summer internships and employment now, I've been trying to hone my coding skills. I decided to implement my own version of network-to-host-long-long (ntohll) for 8-byte integers using bitwise operators in C. Operates similar to ntohs(short s).


This was for a group networking protocol assignment in my data networks class.


It was challenging, although time consuming, and later I found a much more elegant solution on the internet. But this my ugly bastard child and I'm keeping it.


Network to Host Long Long (Source Code)

/**
* Determines the host machine's endianness.
*
* @return 1 if Little Endian, 0 if Big Endian
*/

int checkEndian () {

void * p;
unsigned short * shortP;

unsigned char buffer[2];
p = (void * ) buffer;
shortP = (unsigned short * ) p;

* shortP = 0x01;

if (buffer[0] == 0x00){
if (debug) {
printf("Big Endian\n");
}
return false;
}

else {
if (debug) {
printf("Little Endian\n");
}
return true;
}

}

/**
* Given a long long number reverse the order of the bytes
* if the machine is Little Endian. Otherwise do nothing and
* return the number.
*
* @param input - network value to be converted to host order
*/
unsigned long long ntohll (unsigned long long input) {
if (checkEndian()){
unsigned long long result = 0;
unsigned long long mask = 0xFF;

if (debug){
// Print INPUT
void * p;
unsigned char * buffer;
p = (void *) &input;
buffer = (unsigned char * ) p;
int j;
for (j = 7; j >= 0; j--) {
printf("%x ", buffer[j]);
}
printf("\n");
}

// Input will be reversed
// Need to reverse all 8 bytes
int i;
for ( i = 0; i < 8 ; i ++){

if (i < 4) {
result = result | ((input & ( mask << (i * 8) )) << (8 * (7 - 2 * i) ));
}
else {
result = result | ((input & ( mask << (i * 8) )) >> (8 * ( 2 * (i - 4) + 1) ));
}
}
// Print resulting value
if (debug) {
void * p;
unsigned char * bufferResult;
p = (void *) &result;
bufferResult = (unsigned char * ) p;
int j;

for (j = 7; j >= 0; j--) {
printf("%x ", bufferResult[j]);
}
printf("\n");
}
return result;
}

// If Big Endian, we can just return value without swapping bytes
else {
return input;
}
}


Thursday, December 2, 2010

Google Visualizations for Final Project (ICS413)

NOTE:
chart size: Width x Height: 410 x 350 (&chs=410x350)
Title Font Size: 16.5 (&chts)
Axis Font Size: 11.5 (default)
Tick marks (y-axis, x-axis): 1,15 (&chxtc=1,15)

Energy Page:
(by Day)

(by Month)

Energy Breakout:
(by Day)

Temperature:
Aquaponics Statistics:
(pH by Day)

Aquaponics:
(Water Quality - Current Quick Look)

Aquaponics Water Reserves
(Current Levels)