Tuesday, March 20, 2007

China Trip - Part 3

There were only a few moments where we caught a glimpse of what everyday life is like for the people of China and a couple of them came on this day of traveling. We continued our journey with a rickshaw ride through some of the older areas of Beijing and then we took a trip to the Temple of Heaven. As we walked the long corridor to the temple, we saw a large group of people playing cards, dancing, and making music. It was a glimpse of life that I would like to have taken part in, but I felt like an outsider. I'm still not sure what card games they were playing. The Temple of Heaven was a breathtaking structure and from the top of the hill you could see the entire city.

Tuesday, March 13, 2007

China Trip - Part 2

   I'm picking up my narrative on the second half of the first full day in which we visited the Great Wall. It was absolutely breathtaking and the pictures don't do it justice. You could see the wall winding through the mountains for miles standing dark against the new fallen snow.

The next morning, we visited Tiananmen Square and the Forbidden City. It was extremely cold when the wind picked up, but the sights were impressive. The Forbidden city is quite a palace, and the bold colors and detailing have been recently restored in preparation for the Olympics. One of the largest buildings was still under wraps. I was struck by the size of the palace. As I walked through the last few corridors I thought I was nearing the end only to walk into a massive courtyard. I think it was about seven courtyards, but don't quote me on it. (Check out the satellite image on Google Maps.) In my next post, I'll write about our rickshaw ride through Beijing and our visit to the Temple of Heaven.

Sunday, March 11, 2007

China Trip - Part 1

Vanessa and I just got back from our trip to China and I'm going to spread out some of the details over several days. We took over eight hundred pictures, so I'll be sharing a few from each of the days. In this first (of many) posts about the China trip I'll talk about our first day of sight seeing in Beijing.

It snowed on our first morning in China and it was a welcome if not shocking change from the weather back home. I've been missing the snow since I moved to California so it was good to be in it again, even if it made walking around a bit difficult. We started the day with a short tour of the Summer Palace, which was a gift from the emperor to his mother for her 60th birthday. It was quite a gift, a man made lake and acres of gardens.

After seeing the palace, we traveled to the Ming Tombs and visited the largest tomb. The buildings were massive and filled with artifacts buried with the emperors of days long gone by. The styles and designs of the ancient crowns and armor were very interesting and not quite what I was expecting. If you'd like to see more pictures, I'll point you to a place where you can view them. Tune in for more details from the trip in the very near future.

Wednesday, February 28, 2007

We're going to China

My wife and I leaving for China in the very near future. We're both really excited, I've never been to the eastern hemisphere before and I'm looking forward to experiencing a different culture. The trip will also give Vanessa plenty of opportunities to practice her Chinese.

I'll have a vast array of experiences to share with you, gentle reader, upon our return. So for now I'll leave you with some half finished thoughts. I started no less than three blog posts over the past two weeks, but they are all sitting as unfinished drafts. Here's a brief summary of one of the things I started to talk about. (In the end it turned out to be not quite so brief.)

Cellular Automata
I've been looking into Cellular Automata recently as a source for complex data interactions. There has been some discussion among cryptographers about the use of cellular automata as possible pseudo random number generators. The best known example of a cellular automata is John Conway's Game of Life and I think it illustrates the kind of complex interactions which can occur within a cellular automaton, even though it is a "universe" with very few rules.

I started to look at the behaviors in Wolfram's rule 30 and rule 110 cellular automata because those have been selected as possible candidates for cryptographic systems. I wrote a program to evaluate patterns produced by these rules in a finite two dimensional field which wraps on both ends. I think I may have found other rules which may also prove promising for cryptographic use, but I need to do more evaluating. I'd ultimately like to use a three, four, or five dimensional system to see if I could build a useful PRNG but I will need to spend considerably more time ensuring that the patterns created by the rules remain complex. In the 2D system I evaluated, the vast majority of rules produces very predictable patterns.

See you when I get back.

Friday, February 02, 2007

Simulating Classes in C - Part 2

Well the $1 C contest has come to an end after generating lots of interest but no full blown solutions. I'm okay with that, thanks to all of you who expressed interest and started on it. From conversations with several of you over chat, I know that there were some great ideas out there. If you don't mind taking the time, please describe your idea in the comments section. As my friend Matt can attest, I love discussing software, ideas, designs, and just about anything related to creative problem solving. This is probably why I really enjoyed math in high school and college. I looked at each problem as a logic puzzle which could be solved multiple ways. Finding the most elegant solution made me feel like I had just written a poem of supreme beauty.

/* JSObject functions */
void InvokeObjectMethod(JSObject* object, char* methodName,
JSListOfObjects* inputParams,
JSListOfObjects* outputParams) {
int i;
JSClass* class_of_object;
int method_index = -1;

/* Impossible to invoke a method on a NULL pointer */
if(object == NULL) {
/* ToDo: send a "NULL object" error code in the outputParams. */
return;
}

class_of_object = (JSClass*)(object->type);

if(class_of_object == NULL) {
/* ToDo: send a "NULL class" error code in the outputParams. */
return;
}

/* Find the index of the methodName in the object's class. */
/* This part of the code is O(n) efficient, but this could be
improved if the function names were sorted or if a hash
algorithm was used. Hashing could reduce to O(1). */
/* I could also allow the calling code to specify the desired
method directly by index to avoid requiring a string
lookup for each invocation. */
for(i = 0; i <>method_count; i++) {
if(strcmp(class_of_object->method_names[i], methodName) == 0) {
method_index = i;
break;
}
}

/* If the method name was not found in the list of class methods,
return an error code. */
if(method_index == -1) {
/* ToDo: send a "method not found" error code in the
outputParams. */
return;
}

/* Invoke the method at the index corresponding to the method
name. */
(*(class_of_object->methods[method_index]))(object, inputParams,
outputParams);
}

I wrote my solution a few weeks ago, then started researching how other object oriented schemes are implemented. I found out that my code has several disadvantages and some significant advantages as well. For example, I started to comapre the likelyhood of missing the RAM cache to solutions in C++ and Java. There were a few other intersting comparisons but I won't go into all of the nitty gritty details. Overall, I'm very pleased because I learned a lot. Lets discuss!

Tuesday, January 23, 2007

What is ogg vorbis?

I'm glad that you asked. Ogg Vorbis is a format for music files like MP3. In many ways, I think that Ogg Vorbis is better. It produces higher quality output at a lower bit rate than MP3's. This means Ogg Vorbis files sound better and are smaller than MP3 files. In addition, Ogg Vobis is an open format and it uses open source software. This means that if you wanted to create an Ogg Vorbis player, or write a program that uses Ogg Vorbis, you don't need to pay any licensing fees on the technology. The MP3 format is patented by a German company (Fraunhofer Society) and they charge licensing fees to use it.

So, why isn't it more popular you may ask? I think it all comes down to timing. Ogg Vorbis was introduced much later than MP3, and several MP3 codecs have been released as free software for individual use. I'm hoping that Ogg Vorbis will gain momentum and eventually win out.

If you are interested in free and open audio compression you might also want to check out the Free Lossless Audio Codec (FLAC). The is no degradation to the quality of the sound and it is free and open like Ogg Vorbis.

Wednesday, January 10, 2007

Simulating classes in C

I have to admit, I like to program in C. In some ways, it is simpler than some of the newer, high level languages, and I really enjoy being closer to the machine code. Perhaps I'm a bit obsessive about efficiency. Still, I sometimes long for classes and objects in my C programs, (This is where you tell me that I should use C++ or Objective-C.) so I decided to figure out how I could simulate classes in plain old ANSI C.

It turned out to be quite easy. After I read up on function pointers, I created a struct which contains references to functions (kind of like class methods). Here's a simple example of what I'm talking about:

#include<stdio.h>

typedef struct {
int (*test)(int); /* This is the function pointer */
} functionholder;

/* At runtime, I will point to this function */
int thefunction(int x) {
printf("thefunction says %i\n", x);
return 0;
}

int main() {
functionholder fholder;
fholder.test = &thefunction;
(*fholder.test)(7);
return 0;
}

When I run the above, the program prints "thefunction says 7".
From there, I decided to create a family of structures which would simulate classes, objects, and allow polymorphic function calls.

One way to divide up data and methods in an OO way is to say that the class dictates the methods which can be used with the data in an object instance. So we could say that a class contains a list of functions. Using function pointers, the method called can be changed at runtime, as long as all of the functions have the same stack profile. Have I lost you yet? So what I needed to do was create a generic function prototype which abstracts the parameter list into a common format. While I was at it, I decided to lose the restriction that methods return only one value, so the results of a method call will be stored in a structure which is passed in as a parameter. (The method should probably be called a procedure instead of a function.) Perhaps it would be simpler to show you the code.

typedef struct {
void* type; /* This will point to a JSClass. */
void* data;
} JSObject;

typedef struct {
int object_count; /* number of objects in the array */
JSObject** objects; /* An array of pointers to JSObjects */
} JSListOfObjects;

typedef struct {
char* name;
/* Each JSClass contains a list of pointers to the methods which belong
* to that class. */
int method_count;
/* strings naming the functions (allow method lookup by string) */
char **method_names;
/* An array of pointers to functions */
void (**methods)(JSObject* x, JSListOfObjects* y, JSListOfObjects* z);
} JSClass;

I was going to discuss the functions I created to streamline "class" method invocation, but this post is getting a bit long. So I've decided to try something fun. I'm going to ask you, gentle reader, to suggest a design for a function which simplifies invocation of an object method. I will mail $1 (USD) to the person who posts the "best" working solution in the comments below. (I'll be compiling using gcc -ansi. Oh, and US residents only, I don't want to run into any strange rules.). In addition to a dollar, you'll have won bragging rights for the first of my blog challenges. After a week or two, I'll post my solution and we can all compare notes. Happy coding!

Saturday, January 06, 2007

A Clockwork Orange

I just finished reading A Clockwork Orange by Anthony Burgess and I would recommend it. If you decide to read it, be prepared for a rip roaring ride of emotions and strange slovos (words). At times, it can be difficult to stomach and after the second chapter, I was ready for the main character to be killed off. (I'd have tolchoked his merzky litso all on my oddy knocky, oh my brothers, 'til the krovvy flowed real horrorshow and his zoobies come all out.) There are some comic moments, (it can be a malankey bit silly) but at it's core, this book explores the deep topics of morality and free will (and all that cal). I've never viddied the movie, but I tend to think that it wouldn't come off so well. Some things just work better in print.

Monday, December 04, 2006

Wii have a Wii

This weekend my wife and I joined some friends to wait in line to buy a Nintendo Wii. My friend m3tus had a hot tip that the local Circuit City had exactly 27 units which they were going to sell on Sunday morning. Vanessa and I arrived at 2:30 AM for place number 18 in line. (Two friends of ours had arrived earlier.) It was quite cold, but we came prepared with a tent, sleeping bags, camp chairs, and quite a few layers of clothes. We even managed to catch some zzz's in the wee (wii?) hours of the morning. I think line member number 27 arrived at 4:30. He almost left, but Vanessa told him that the two of us were only getting one, so he would be the last to get one.

A couple of trips to a 24 hour Safeway and a nap later, some of the Circuit city employees arrived to hand out vouchers. I think it was around 8:00 AM (the store opens at 10:00). We packed up our gear and hit Denny's! Ah sweet food.

We returned to the store to find a long line of customers all waiting to get a Wii and Wii accessories. Some employees announced that they had already given out vouchers, and that all ticket holders should move to the front and form their own line. They called out tickets in order and we paid for our Wiis. My friend m3tus wanted to make sure that no one tried to take his. So he claimed it the old fashioned way and licked it! This would have made a great picture, I wish I had known he was going to do it. The whole line had a good laugh. Then it was time to head home and get some proper sleep. Are we getting too old for this?

Wednesday, November 29, 2006

Pomegranates!

A couple of weeks ago I had a pomegranate for the first time. Eating it was quite an intricate task, made all the more so by the challenge in keeping pomegranate juice off of my clean white shirt. (It's a new favorite of mine and states proudly "Debugging Sucks. Testing Rocks.", but I digress.) If you have the chance to try one, do it! I've never eaten anything quite like it. I think I would describe the inside as if someone shrank red (seeded) grapes and made the grow on the inner wall of a squash. Check out the pictures.

Wednesday, November 01, 2006

A Steganography Scheme - Part 2

My text based steganography program is here! I completed the program yesterday, and Vanessa came up with a great name: Steganosaurus. Get in touch with me if you would like me to send you the program and the source code. I'm still considering publishing it on an open source hosting site.

You may recall my previous post about this steganography scheme, and I said I would tell you how it all works. So here goes:

My steganography program needs 4 pieces of information to embed or extract a secret message, it needs a file which will be converted, the base, the shift value, and a filename to which the converted message will be stored. The base and shift need a bit of explanation.

Base: All data on a computer is a number, and a number can be expressed multiple ways. I wrote about this in "A Steganography Scheme - Part 1". So the base tells Steganosaurus how to express the data. Should each number in the source file be converted into a series of values between 0-10, 0-50, 0-200? The choice is yours.

Shift: My program outputs a range of values from the source file, and each of them is between 0 and Base. How does this become readable text? That is the purpose of the shift, it is a value added to each piece of the converted file to make it into a character. So the result of the whole process is the contents of the original file expressed as numbers in the range Shift to Base + Shift. These numbers are converted into Unicode characters (UTF-8) so the end result is a readable file. You can see an example in my wiki entry about Steganosaurus. (It's probably easiest to see an example.) By using different shift values, you can hide the data from your original file in text from any language in the world.

So check it out, give it a shot, and ask me to send Steganosaurus to you.

Thursday, October 19, 2006

Some random items

Usually, my blog posts center on one theme or one idea which I try to explore in depth. Tonight I'm not feeling so focused, so here is a scatterbrained snapshot, developed from my tired mind. It has been a long week.

What am I up to?

I wanted to write a quick update, because it has been a while. I'm still working on my steganography project. I decided to build UTF-8 support into it, and this has complicated things slightly, but it's good because I'm learning new things. I spend an hour or two on it a couple of days a week and it is coming along quite well.

I'm reading a book. Neverwhere by Neil Gaiman and I'm really enjoying it. Many thanks to m3tus for letting me borrow it. I will probably finish it on the flight tomorrow.

And where is this flight taking me you might ask. Well, homecoming of course (this is for my University, just to clarify). I'm looking forward to meeting old friends and hanging out in the old haunts, so to speak.

And now I will close with a random link: http://206.220.43.61/primespeaks/votePrime/. I don't know if you have heard about the upcoming Transformers movie. I'm mildly interested because this was one of my favorite shows when I was very young. Apparently, they are having a contest to choose a line which will be said by Optimus Prime during the movie. The whole thing seems like a giant publicity stunt (and a way to collect email addresses), but it is kind of fun to watch people try to hijack the election to choose the line. One individual was campaigning to get the line "I Guess I'll Transformer Into A Truck Now." entered into the contest. Unfortunately his line didn't make it. Personally, I'm pulling for "These pretzels are making me thirsty!"

Random.

Friday, October 13, 2006

Seeking Simplicity

Simplicity. Life can so easily get too complicated. I often feel that it is so already, and there is still so much ahead of me. So I've been thinking about how to simplify my life, I've even been reading about it. If you are looking for a good book to read, check out Celebration of Discipline by Richard Foster. I read through it a couple of years ago and found it to be extremely refreshing. The perspective offered by Richard Foster is quite different from that we usually find in our affluent, consumer culture.

Speaking of simplicity, I've been complicating my web presence by creating a new webpage and signing up for del.icio.us. I wrote more about it a couple of days ago on my wiki page.

Saturday, September 30, 2006

A Steganography Scheme - Part 1

I've been thinking lately about steganography. Previous tools have hidden information in images, videos, sound files, and other large chunks of information. But I have not seen many examples of steganography with text (here is one). I decided to put together a simple and flexible text steganography tool just for fun.

The secrecy in a stegonography scheme rests in a shared algorithm between the sender and receiver which is not known by those trying to intercept the message and the fact that a hidden message is not apparent in the message being sent between the individuals. Anyone trying to find the hidden message faces two challenges:
  1. How do I know when a hidden message is present?

  2. How do I extract the hidden message?

Because I am explaining my stegenography idea to the world at large, item number two is no problem. I hope that the first question will not be so easily answered. In any case, you should not rely on this, or any other steganographic method to keep a secret. For that, you need encryption.

Now, on with the scheme!

I wanted users of my system to be able to send any kind of data by hiding it in a plaintext message. In order for the information to be hidden in text, it may have to be converted from one form to another. The same information can be expressed in multiple ways. For example, the number 14 can also be expressed as 1110 (binary), 16 (octal), and E (hexadecimal), depending on the encoding or base of the information. When information is converted into another form, someone who is decoding or reconstructing the information needs to know what form it is stored in. In many steganography schemes, the form of the data is constant and is a secret shared only by those who are supposed to be able to read the hidden message. I wanted to allow flexibility in the encoding, or alphabet, which is used to express the hidden message, so a message from my system will include a definition of the alphabet used to hide the secret message. Here are the steps for using my scheme:
  1. Write the secret message

  2. Choose an alphabet to encode with

  3. Convert the secret message to the desired alphabet

  4. Embed the converted secret message into an innocuous public message.

Now I've shared with you what it is that my steganography scheme will do. In my next post, I'll talk about how.

Tuesday, September 19, 2006

Back on the Internet


It's good to be back on the Internet. My wonderful wife and I relocated a couple of weeks ago to our new domicile and our connection was set up today. A lot had happened while I was out. The facebook newsfeed situation was addressed, new Strong Bad emails were released, and, best of all, my uncle Doug signed up on myspace and has written a mighty fine blog (rss feed). It seems that my return to cyberspace was none too soon:

So, I've been on myspace for a couple of days now. My profile echos when it loads, a soft lonely sound. Tom's still smiling away like a leprechaun (I should be having so much fun), lovin' you Tom, you haven't removed yourself from my page, yet. Off in the distance I hear crickets or is that my knees? Anyway, I'm waiting in breathless anticipation for at least my wack-job nephew and his lovely, vivacious bride to answer my request to be their friend. Maybe someone in an induced stupor of some sort will accidently stumble upon my page and be touched by my incessant whining and think to themselves "that poor bastidge, I'm gonna be that fargin' Snuncle_Fudge's friend!!"*

Good show Uncle!

* Quoted directly from Doug's blog, a Doug's blog production, copyright Doug 2006, all rights reserved, available for a limited time only, while supplies last, act now and get two for the price of one, a $50 value for only $19.99.

Sunday, September 03, 2006

Reviving my laptop

I have an old laptop which I would hate to see go to waste, an Intel 796 megahertz processor with 128 megabytes of ram and the weight of Windows XP has become too much for it to bear. I want a system that will run quickly and smoothly. I need a web browser and programming tools (gcc, make, python, perl, svn, etc.) and an mp3 player might be nice too. I had been running OpenSUSE, but the performance was still a bit sluggish. Then I tried Damn Small Linux (DSL) and it had almost everything I need. Fluxbox is a great windowing system and it ran extremely well. Things started to break down when I tried to install make, a series of dependencies and library downgrades prevented me from being able to get everything I needed. The problems continued the more I tried to modify the system. So I've tried others, five distributions so far, but none seem to work just right. This is turning into quite the weekend project.

Saturday, August 26, 2006

Facebook badge

I stumbled across Facebook's badge feature today. It's pretty nice I must say. Simple, easy to use, and in keeping with Facebook's clean style. I'm on both Facebook and Myspace and I must say I have preferred Facebook thus far. Who knows, maybe Myspace will change for the better. I could do without audio and video clips embedded on Myspace pages. I want to control the noise that comes out of my computer and I make a point to disable all sound effects, warning bells, audible chat alerts, etc. Nothing should get in the way of my music while I'm surfing the web.

Jeffrey Scudder's Facebook profile

Wednesday, August 23, 2006

My TiddlyWiki

I recently tried out TiddlyWiki (http://www.tiddlywiki.com) and I've used it to created a simple page which I plan to update periodically (http://jeffrey.scudder.googlepages.com/PublicWiki.html). It has some information about the projects I'm working on in my spare time, other web real estate on which my face is pasted, and it serves as a collection of blogs and posts in other domains. I've become almost addicted to TiddlyWiki while using it for brainstorming and organizing my thoughts. As I'm writing, I can easily mark a topic for further explanation by writing a WikiWord. It turns my browser into a rich text editor. Quite a nifty little doodad. I'm curious to see what happens when the HTML file grows to a massive size.