I have now had the Wii for a whole week. You may want to read my initial review.
In the past week I have come to see just how big of an impact the Wii is going to have on gaming. For Thanksgiving, I had my parents and grandma over. My family including my grandma, were able to play Wii Golf and had a great time doing it. The Wii really does appeal to all ages it seems. I don't think I have ever seen that much excitement and fist pumping from my family ever when playing video games.
Now for a few more reviews of games.
Madden
The Wii is absolutely a perfect match for Madden. It is so much easier when in order to juke or stiff arm, all you have to do is wave the nunchuck or wiimote, instead of trying to press button on the control. It really improves your timing when doing moves and makes juking and stiff arming actually useful. The same can be said for playing defense. Jumping to intercept the ball by raising both the nunchuck and wiimote in the air or swatting the ball just by waving the wiimote is very much intuitive. The only regret that I have is it not having internet play. I hope the next version does.
Monster Truck 4x4
This game is very easy to play. The steering handles exceptionally well. The only problem with the game is that you can beat it in 90 minutes in single player mode. Aside from that though, it is still a very fun multiplayer game for racing your friends, or even playing soccer by pushing the ball with your truck!
Rayman
All I can say is, this game rocks! From throwing cows to hitting bunnies, this game has it all. It is very comical and addicting. The only reason I was stopped from playing was when my kitty hit the power button on the surge protector. Be careful! I already know one other person who is insanely addicted to this game.
Tuesday, November 28, 2006
Wednesday, November 22, 2006
You heard him, let's pay the man for Linux.
Tristan Sloughter has posted a blog post about how Steve Ballmer and Microsoft want to extort us Linux folk for the rights to use free software. In response, Tristan suggests we start a campaign of mailing monopoloy money to Steven Ballmer. I am definitely all for it! Only problem is, I am not just going to handover my hard earned Monopoly Money! Good Hasbro has PDF's on their site to print some out! I recommend printing the 500's. Just to make sure you pay enough to get Microsoft off your back.
Money:
http://www.hasbro.com/monopoly/pl/page.treasurechest/dn/default.cfm
Address:
Microsoft Corporation
c/o Steven Ballmer
One Microsoft Way
Redmond, WA 98052-7329
Spread the word!
Also on reddit.
Money:
http://www.hasbro.com/monopoly/pl/page.treasurechest/dn/default.cfm
Address:
Microsoft Corporation
c/o Steven Ballmer
One Microsoft Way
Redmond, WA 98052-7329
Spread the word!
Also on reddit.
Labels:
ballmer,
free,
freedom,
freesoftware,
gnu,
gnulinux,
linux,
microsof,
steve,
t extortion
Wii: First Impressions
I received my Nintedo Wii yesterday. I was lucky enough to have ordered one from Circuit City during the few minutes that they took preorders on Friday. They shipped it out Monday, and it was here Tuesday(yesterday). Anyways, here are my first impressions of some different aspects about the Wii.
The Wii Itself
I must say the thing is even smaller than I could have imagined. It is slightly slimmer than a Mac Mini, a little longer, and just a tad wider. The thing feels absolutely solid. The controllers(Wiimote and Nunchuck) are also very solid. The Wiimote even comes with a wrist strap, so you don't have to worry about flinging the thing out of your hand. When I first heard it would have a strap, I figured I wouldn't use it, since it would probably be annoying. That is nowhere near the case. You can barely even notice it is on, yet it gives you that extra security that you don't have to worry about dropping your brand new 30 dollar Wiimote on the floor.
Setup
Setup was an absolute breeze. Just plug in the power, A/V cables, and the Wii sensor bar, and you are on your way. The initial screen just asks you to specify a name for your box and the date. From there setting up the wireless is just as easy by going to the options. There is a system information section that tells you what your MAC address is if you do MAC filtering. Also, the wireless gives you all the major choices for WEP and WPA encryption if you have those enabled on your router. After that, it goes through an update. The update took me about 5 minutes, I am guessing because the server is probably a little bogged down at the moment, but nothing too bad.
Game Play - Wii Sports
I of course started by playing Wii Sports Baseball! Both my girlfriend and I had an absolute blast. The pitching and batting is very intuitive and fun. You even kind of get a workout if you don't cheat and really go through all the motions. It actually feels like you are playing baseball(at least way more so than any other baseball game I have played). In case you are wondering how you run the bases, don't worry about it, you can't! When you hit the ball, the computer basically estimates if you would have been out, or if not, how many bases you would have got.
From there we went to Tennis. Again, and absolutely fun experience. You hold the remote just as if you would the handle of a tennis racket and swing away! The remote even seems to account for what your racket angle would be an applies the appropiate spin and aim on the ball.
After that we played boxing. This was probably my least favorite of the Wii Sports games. It was fun, but it seemed kind of clunky feeling, and not all of your punches would always be registered. It could just be that I need to get more used to it.
Next was Golf. Again very inuitive, and very fun. Just like tennis, except you are swinging at the ground, the game registers the angle and spin off your club, as well as the velocity of your club to determine the speed of the ball of the club. Putting was a little challenging at first, but then again, it is challenging for me in real life too.
Finally there was bowling. This was also tons of fun. I imagine this game will be the game to play when you have friends over, as you don't need 4 remotes to have 4 people play, just hand the remote over. The game is addicting and really does require that you aim your shot, and bowl the ball with the right power and angle.
Game Play - Red Steel
I haven't gotten too far into Red Steel, but so far it has been fun. It is a little tricking getting used to using the Wiimote to turn yourself around and look up and down while using the Nunchuck to actually move. Also, sometimes it seems like the Wiimote gets a little confused and has you staring at the sky for a couple of seconds before it figures out what you want. Other than that, the game is alot of fun, and I think shooting people in the game with the Wiimote is easier then even using a mouse on a computer. You also get to do sword fighting with the Wiimote which actually follows your moves fairly well and seems pretty accurate.
Overall
Overall I would say that the Wii is the best system I have ever played. You can really tell it is made for anyone, even non-gamers. Nintendo seems to have this down to a science. Whenever you start thinking to yourself, "Well, how do I do that!" it seems at that moment Nintendo always has a little message bar telling you what you need to know. Along with these well placed helpful hints, the gameplay is simple and intuitive enough that the playing field for everyone is even. My GF beat me in Bowling and Baseball, and I beat her in Tennis and Golf. It really does not depend on how much of a gamer you are, but rather just doing it and trying to have some fun!
The Wii Itself
I must say the thing is even smaller than I could have imagined. It is slightly slimmer than a Mac Mini, a little longer, and just a tad wider. The thing feels absolutely solid. The controllers(Wiimote and Nunchuck) are also very solid. The Wiimote even comes with a wrist strap, so you don't have to worry about flinging the thing out of your hand. When I first heard it would have a strap, I figured I wouldn't use it, since it would probably be annoying. That is nowhere near the case. You can barely even notice it is on, yet it gives you that extra security that you don't have to worry about dropping your brand new 30 dollar Wiimote on the floor.
Setup
Setup was an absolute breeze. Just plug in the power, A/V cables, and the Wii sensor bar, and you are on your way. The initial screen just asks you to specify a name for your box and the date. From there setting up the wireless is just as easy by going to the options. There is a system information section that tells you what your MAC address is if you do MAC filtering. Also, the wireless gives you all the major choices for WEP and WPA encryption if you have those enabled on your router. After that, it goes through an update. The update took me about 5 minutes, I am guessing because the server is probably a little bogged down at the moment, but nothing too bad.
Game Play - Wii Sports
I of course started by playing Wii Sports Baseball! Both my girlfriend and I had an absolute blast. The pitching and batting is very intuitive and fun. You even kind of get a workout if you don't cheat and really go through all the motions. It actually feels like you are playing baseball(at least way more so than any other baseball game I have played). In case you are wondering how you run the bases, don't worry about it, you can't! When you hit the ball, the computer basically estimates if you would have been out, or if not, how many bases you would have got.
From there we went to Tennis. Again, and absolutely fun experience. You hold the remote just as if you would the handle of a tennis racket and swing away! The remote even seems to account for what your racket angle would be an applies the appropiate spin and aim on the ball.
After that we played boxing. This was probably my least favorite of the Wii Sports games. It was fun, but it seemed kind of clunky feeling, and not all of your punches would always be registered. It could just be that I need to get more used to it.
Next was Golf. Again very inuitive, and very fun. Just like tennis, except you are swinging at the ground, the game registers the angle and spin off your club, as well as the velocity of your club to determine the speed of the ball of the club. Putting was a little challenging at first, but then again, it is challenging for me in real life too.
Finally there was bowling. This was also tons of fun. I imagine this game will be the game to play when you have friends over, as you don't need 4 remotes to have 4 people play, just hand the remote over. The game is addicting and really does require that you aim your shot, and bowl the ball with the right power and angle.
Game Play - Red Steel
I haven't gotten too far into Red Steel, but so far it has been fun. It is a little tricking getting used to using the Wiimote to turn yourself around and look up and down while using the Nunchuck to actually move. Also, sometimes it seems like the Wiimote gets a little confused and has you staring at the sky for a couple of seconds before it figures out what you want. Other than that, the game is alot of fun, and I think shooting people in the game with the Wiimote is easier then even using a mouse on a computer. You also get to do sword fighting with the Wiimote which actually follows your moves fairly well and seems pretty accurate.
Overall
Overall I would say that the Wii is the best system I have ever played. You can really tell it is made for anyone, even non-gamers. Nintendo seems to have this down to a science. Whenever you start thinking to yourself, "Well, how do I do that!" it seems at that moment Nintendo always has a little message bar telling you what you need to know. Along with these well placed helpful hints, the gameplay is simple and intuitive enough that the playing field for everyone is even. My GF beat me in Bowling and Baseball, and I beat her in Tennis and Golf. It really does not depend on how much of a gamer you are, but rather just doing it and trying to have some fun!
Wednesday, November 15, 2006
Adding AES Encryption To Erlang Chat
I have been working on adding encryption to an IRC clone that I am working on with Tristan Sloughter called EChat.
Just like IRC, in normal operation EChat sends all communications to the server, then the server figures out who needs to get what. So, for my initial stab at adding encryption to EChat, I decided to encrypt the transmissions between clients and the server, instead of end to end.
Client1 <--Key1--> Server <--Key2--> Client2
So basically, the server does all the key management. Since AES requires a symmetric 128-bit key, we need a method of having each client the server generate a key. That is where Diffie-Hellman(DH) comes in!
DH is a quick and easy way to create symmetric keys between two people without ever having to reveal what the key actually is in plain text.
DH can be explained alot better here, than I can do, so I won't spend the time going over it. However I will talk about a few specifics of my implementation in Erlang.
In the algorithm, a and b both need to be a certain size in order to guarantee there are 128 bits in the final key. Therefore, to create them I simply did the following:
For the curious, 2^127+1 = 170141183460469231731687303715884105729,
and 2^128-1 = 340282366920938463463374607431768211455. Generating a number in this range assures us we get a number that is at least 128 bits.
Also, to generate g and h, I just did the following:
gen_DHp() -> gen_DHg().
gen_DHg() -> make_prime(50).
On the client side, we calculate A as follows:
DHg = ecrypt:gen_DHg(),
DHp = ecrypt:gen_DHp(),
DHa = ecrypt:gen_DHa(),
A = crypto:mod_exp(DHg, DHa, DHp).
On the server side we calculate B as follows:
DHb = ecrypt:gen_DHb(),
B = crypto:mod_exp(DHg, DHb, DHp).
Now the client and server exchange A and B, and each can calculate the key
appropriately:
Client: Key = crypto:mod_exp(B, DHa, DHp).
Server: Key = crypto:mod_exp(A, DHb, DHp).
Now we have a key that is at least 128 bits. We want to make sure it is exactly 128 bits though, so I wrote the following function that ensures this. All it does is generate exactly 16 bytes from the stream of bits:
Now that we have a 128-bit symmetric key for both the client and server, we can start using AES encryption!
To find out about AES, read here. Basically AES requires an initialization vector(IV) for each message, as well as a symmetric key, and whatever text you want to encode.
To create the Encrypt and Decrypt functions, I decided just to append the IV to the front of each message sent. The IV does not need to be kept secret, and is only used to deter statistical attacks on the encrypted message. Thus, the following code shows how I did the encrypt and decrypt:
That's all there is to it! Now you can add AES encryption to your application, whether it is for messaging or file storage. If you would like to find out more about the Erlang AES implementation, go here.
Just like IRC, in normal operation EChat sends all communications to the server, then the server figures out who needs to get what. So, for my initial stab at adding encryption to EChat, I decided to encrypt the transmissions between clients and the server, instead of end to end.
Client1 <--Key1--> Server <--Key2--> Client2
So basically, the server does all the key management. Since AES requires a symmetric 128-bit key, we need a method of having each client the server generate a key. That is where Diffie-Hellman(DH) comes in!
DH is a quick and easy way to create symmetric keys between two people without ever having to reveal what the key actually is in plain text.
DH can be explained alot better here, than I can do, so I won't spend the time going over it. However I will talk about a few specifics of my implementation in Erlang.
In the algorithm, a and b both need to be a certain size in order to guarantee there are 128 bits in the final key. Therefore, to create them I simply did the following:
gen_DHa() -> gen_DHb().
gen_DHb() -> crypto:rand_uniform(170141183460469231731687303715884105729,
340282366920938463463374607431768211455).
For the curious, 2^127+1 = 170141183460469231731687303715884105729,
and 2^128-1 = 340282366920938463463374607431768211455. Generating a number in this range assures us we get a number that is at least 128 bits.
Also, to generate g and h, I just did the following:
gen_DHp() -> gen_DHg().
gen_DHg() -> make_prime(50).
On the client side, we calculate A as follows:
DHg = ecrypt:gen_DHg(),
DHp = ecrypt:gen_DHp(),
DHa = ecrypt:gen_DHa(),
A = crypto:mod_exp(DHg, DHa, DHp).
On the server side we calculate B as follows:
DHb = ecrypt:gen_DHb(),
B = crypto:mod_exp(DHg, DHb, DHp).
Now the client and server exchange A and B, and each can calculate the key
appropriately:
Client: Key = crypto:mod_exp(B, DHa, DHp).
Server: Key = crypto:mod_exp(A, DHb, DHp).
Now we have a key that is at least 128 bits. We want to make sure it is exactly 128 bits though, so I wrote the following function that ensures this. All it does is generate exactly 16 bytes from the stream of bits:
integerlist_to_key([], Key, _) -> lists:concat(lists:sublist(Key, 16));
integerlist_to_key([Head | Tail], Key, Tmp) ->
Test = list_to_integer(lists:reverse([Head | Tmp])),
if
Test > 255 -> integerlist_to_key(Tail, [list_to_atom([list_to_integer(Tmp)])| Key], [Head]);
true -> integerlist_to_key(Tail, Key, lists:reverse([Head | Tmp]))
end.
Now that we have a 128-bit symmetric key for both the client and server, we can start using AES encryption!
To find out about AES, read here. Basically AES requires an initialization vector(IV) for each message, as well as a symmetric key, and whatever text you want to encode.
To create the Encrypt and Decrypt functions, I decided just to append the IV to the front of each message sent. The IV does not need to be kept secret, and is only used to deter statistical attacks on the encrypted message. Thus, the following code shows how I did the encrypt and decrypt:
encrypt(Message, Key) ->
IV = crypto:rand_bytes(16),
list_to_binary([IV] ++ [crypto:aes_cfb_128_encrypt(Key, IV, Message)]).
decrypt(Message, Key) ->
{IV, Crypt} = lists:split(16, binary_to_list(Message)),
binary_to_list(crypto:aes_cfb_128_decrypt(Key, list_to_binary(IV),
list_to_binary(Crypt))).
That's all there is to it! Now you can add AES encryption to your application, whether it is for messaging or file storage. If you would like to find out more about the Erlang AES implementation, go here.
Labels:
aes,
chat,
cryptography,
dh,
diffie-hellman,
echat,
encryption,
erlang,
irc
Tuesday, November 14, 2006
Sensationalism in the GNU/Linux world
Today I came across the following blog post entitled Is Ubuntu Set to become Non-free?
Basically they complain how Ubuntu is going to want you to use proprietary drivers for using the default composite manager. The thing that bugs me is that Ubuntu is already non-free. Their own philosophy(which the author even states) specifically says they allow for specific cases of having non-free software. To me, you can't be slightly free or non-free, you are either free, or you are not, it is just that simple.
Try telling that to digg readers though. It is funny to go through their comments on this article, and read many of them say "No", Ubuntu is not going to become non-free.
I think Ubuntu and Debian are both partially to blame here. They pretend they are "free" when really they are not, so now a mass of people believe that is what having a free distribution means. More importantly though, sensationalist posters who are just merely looking to grab attention of the digg crowd are to blame. Why someone would goto the trouble to distort facts and ramble about misleadings just to get a reaction from the digg crowd is beyond me. I guess some people really are just that narcissistic.
Basically they complain how Ubuntu is going to want you to use proprietary drivers for using the default composite manager. The thing that bugs me is that Ubuntu is already non-free. Their own philosophy(which the author even states) specifically says they allow for specific cases of having non-free software. To me, you can't be slightly free or non-free, you are either free, or you are not, it is just that simple.
Try telling that to digg readers though. It is funny to go through their comments on this article, and read many of them say "No", Ubuntu is not going to become non-free.
I think Ubuntu and Debian are both partially to blame here. They pretend they are "free" when really they are not, so now a mass of people believe that is what having a free distribution means. More importantly though, sensationalist posters who are just merely looking to grab attention of the digg crowd are to blame. Why someone would goto the trouble to distort facts and ramble about misleadings just to get a reaction from the digg crowd is beyond me. I guess some people really are just that narcissistic.
Labels:
free,
freedom,
freesoftware,
fsf,
gnu,
gnulinux,
linux,
sensationalism,
ubuntu
Monday, November 13, 2006
Richard Stallman Talk
The pictures for Richard Stallman's talk is now up on my flickr page. You can view all of them here: http://flickr.com/photos/diginux/sets/72157594369802498/
Also, if you would like to hear the audio of the speech, go here: http://www.chicagolug.org/uploads/4/49/RMS.ogg
Also, if you would like to hear the audio of the speech, go here: http://www.chicagolug.org/uploads/4/49/RMS.ogg
Sunday, November 12, 2006
gNuisance (aka gNewSense)
Very recently the FSF announced a new Free GNU/Linux distro gNuisance. I fully support any and all free software and wish them the best of luck, but I feel their choice of basing gNuisance off of Ubuntu is a poor choice. Right now if you want to use a free GNU/Linux distro, your options are limited, and most of them aren't very fulfilling. That is why I think, instead of branching off of a distro that was branched off of another distro is a bad idea. Other people have already tried this, and it seems that the problems of the original distro(s) holds the new free distro back from its full potential.
It is time all of us free software lovers got together and really start a free "Nu" GNU/Linux distro from scratch. This will allow us to make choices based on what is best for freedom. It also allows us to make the best possible distro out there, so people won't use it just because it is free, but because it is good and they just plain want to use it!
It is time all of us free software lovers got together and really start a free "Nu" GNU/Linux distro from scratch. This will allow us to make choices based on what is best for freedom. It also allows us to make the best possible distro out there, so people won't use it just because it is free, but because it is good and they just plain want to use it!
Friday, November 03, 2006
Idea for System to Conserve Energy
I have an idea in order to make consumers more energy-aware and to conserve more. We should adopt a pay-as-you-go methodology for energy.
For example. When you goto a buffet, you don't eat all the food you want, then have the restaurant decide how much food you have consumed then charge accordingly. Almost no system operate this way except for the energy system. So each month you use so much electricity, then get charged one sum at the end of the month.
I propose instead, that you pay as you go. For example, if you wake up in the morning and want to boil some water for tea, you should have to consciously pay 50 cents(just guessing) to do so. If you want to watch TV, you should have to pay the amount it costs for the electricity to run it for one hour. If we did this, people would more likely make smarter choices, since they are confronted with the consequence of their actions right away. Consumers tend to be more conservative in buying when they are forced to pay upfront, instead of in payments over time.
While I am not sure how easy it would be to implement this idea, I don't think it would be that difficult and it could lead to a future where we are more aware of just how much energy we use/waste.
For example. When you goto a buffet, you don't eat all the food you want, then have the restaurant decide how much food you have consumed then charge accordingly. Almost no system operate this way except for the energy system. So each month you use so much electricity, then get charged one sum at the end of the month.
I propose instead, that you pay as you go. For example, if you wake up in the morning and want to boil some water for tea, you should have to consciously pay 50 cents(just guessing) to do so. If you want to watch TV, you should have to pay the amount it costs for the electricity to run it for one hour. If we did this, people would more likely make smarter choices, since they are confronted with the consequence of their actions right away. Consumers tend to be more conservative in buying when they are forced to pay upfront, instead of in payments over time.
While I am not sure how easy it would be to implement this idea, I don't think it would be that difficult and it could lead to a future where we are more aware of just how much energy we use/waste.
Tuesday, October 31, 2006
Serializing Erlang Tuples For Network Transmission
I have been playing around a bit with setting up an SSL client/server connection between nodes using Erlang. As you have guessed, the SSL module in Erlang expects you to send and receive binary data. You may also know, that the typical way of sending data between nodes in Erlang is by using the '!' operator. For example:
Pid ! {data, SomeList}
Now since the SSL uses sockets to send data, we need to convert from the tuple to a binary form. Luckily, Erlang provides a facility to do this!
On the encoding side all you need to do is use the Erlang term_to_binary Built In Function(BIF):
Data = term_to_binary({data, SomeList})
Then we send it away.
ssl:send(CSock, Data)
Now we receive the data:
{ok, DataRecv} = ssl:recv(SSock, 0)
Then we do the decoding. ssl:send automaticlly converts the binary stream to a list when sending, so we need to convert it back, then go from binary_to_term to reverse our initial encoding.
{ok,OrigData}=binary_to_term(list_to_binary(DataList))
That's all there is to it!
Pid ! {data, SomeList}
Now since the SSL uses sockets to send data, we need to convert from the tuple to a binary form. Luckily, Erlang provides a facility to do this!
On the encoding side all you need to do is use the Erlang term_to_binary Built In Function(BIF):
Data = term_to_binary({data, SomeList})
Then we send it away.
ssl:send(CSock, Data)
Now we receive the data:
{ok, DataRecv} = ssl:recv(SSock, 0)
Then we do the decoding. ssl:send automaticlly converts the binary stream to a list when sending, so we need to convert it back, then go from binary_to_term to reverse our initial encoding.
{ok,OrigData}=binary_to_term(list_to_binary(DataList))
That's all there is to it!
Monday, October 30, 2006
ECal First Beta Release!
I have made my first release of ECal! It is a personal calendar and event organizer written in Erlang. Right now it is just meant for the command line, but later on I will probably make a nice little GUI for it with wxErlang. The program really is nice and handy for those of us who live and breathe on the command line and want a simple way to stay organized and remember meetings.
Weird sites of Chicago
Madeline and I were shooting pictures behind the Oriental Theater, where a famous fire in 1903 killed over 600 people back when it was known as the Iroquois Theater. They used the alley as a temporary morgue to pile all the bodies.
Anyways, as we were shooting, out of nowhere a "lady bum" walks into the alley, pulls down her pants, and does her business.
Click here to see the picture.
Anyways, as we were shooting, out of nowhere a "lady bum" walks into the alley, pulls down her pants, and does her business.
Click here to see the picture.
Friday, October 27, 2006
Visualizing problems in Erlang
Ever since I started learning Erlang almost 10 months ago, I have always just had this deep down unexplainable gut feeling that Erlang is neat. Erlang just feels so right. The flow from idea to implementation in Erlang is so smooth, sometimes I second guess myself, "can it really be this easy?!"
Last night I couldn't sleep, so naturally I stayed in bed thinking about Erlang, and I think I might have figured out why Erlang is so nice: visualization.
Let's just take an example. Let's say I tell you to write Quick Sort in C.
The first thing you would probably do is look up the algorithm which is:
function quicksort(q)
var list less, pivotList, greater
if length(q) = 1
return q
select a pivot value pivot from q
for each x in q except the pivot element
if x < pivot then add x to less
if x = pivot then add x to greater
add pivot to pivotList
return concatenate(quicksort(less), pivotList, quicksort(greater))
To code the algorithm, you need to start thinking about the implementation details, such as how you will manage the pivot list, what type of values will your quick sort support, etc. It is very difficult to go from the algorithm directly to C, there are too many C things to worry about first.
void quickSort(int numbers[], int array_size)
{
q_sort(numbers, 0, array_size - 1);
}
void q_sort(int numbers[], int left, int right)
{
int pivot, l_hold, r_hold;
l_hold = left;
r_hold = right;
pivot = numbers[left];
while (left < right)
{
while ((numbers[right] >= pivot) && (left < right))
right--;
if (left != right)
{
numbers[left] = numbers[right];
left++;
}
while ((numbers[left] <= pivot) && (left < right))
left++;
if (left != right)
{
numbers[right] = numbers[left];
right--;
}
}
numbers[left] = pivot;
pivot = left;
left = l_hold;
right = r_hold;
if (left < pivot)
q_sort(numbers, left, pivot-1);
if (right > pivot)
q_sort(numbers, pivot+1, right);
}
Now let's say I tell you to think about writing a Merge Sort in Erlang. You instantly realize this problem is dead easy using a list a few recursion calls and Erlang's powerful list operators. There are no memory issues to think about, no type checking to worry about, no extra temporary values to handle, no having to "translate" your programs calls to fit the algorithm. With Erlang you can actually imagine in your head, having a long list of things, doing a few list operations, then using recursion and being done.
sort([Pivot|T]) ->
sort([ X || X <- T, X < Pivot]) ++
[Pivot] ++
sort([ X || X <- T, X >= Pivot]);
sort([]) -> [].
While I admit it takes a functional mindset to get used to seeing things this way, once you do have it, it is an almost instantaneous process of going from algorithm to code. Being able to visualize both the algorithm and the Erlang code together at the same time without much difficulty and implementing them immediately makes programming a lot more enjoyable and fulfilling. Gone are the days of tedious details and mindless translations.
References:
1.http://en.wikipedia.org/wiki/Quicksort
2.http://www.erlang.org/doc/doc-5.4.12/doc/programming_examples/list_comprehensions.html
Monday, October 23, 2006
Goodbye Gentoo
I never thought I would say this, but so long Gentoo. I always thought I would be able to stick with Gentoo for most of my life, as it was an easy system to maintain, with a wealth of packages.
Unfortunately Gentoo has been going in a downward spiral for a while now, and finally the final straw has broken the camel's back.
These crazy kids just hard mask anything for fun it seems these days. XMMS, whether "buggy" or not, still works just fine for me, alot better than any of the other current music players out there. I see no reason to hard mask it. Who cares if it doesn't have a maintainer? It still works on x86 computers just fine. I know this gentoo person claims XMMS to be broken, but it works just fine for me. Maybe these days "broken" means they don't release a new version every two weeks.
Anyways, all this rambling is for nothing now, I am officially switching to Ututo.
Unfortunately Gentoo has been going in a downward spiral for a while now, and finally the final straw has broken the camel's back.
These crazy kids just hard mask anything for fun it seems these days. XMMS, whether "buggy" or not, still works just fine for me, alot better than any of the other current music players out there. I see no reason to hard mask it. Who cares if it doesn't have a maintainer? It still works on x86 computers just fine. I know this gentoo person claims XMMS to be broken, but it works just fine for me. Maybe these days "broken" means they don't release a new version every two weeks.
Anyways, all this rambling is for nothing now, I am officially switching to Ututo.
Saturday, October 21, 2006
How to compile wxErlang on Linux
wxErlang is an interface for Erlang to the popular wxWidgets GUI library. Combining Erlang and wxWidgets creates an unbeatable combination for GUI writing. First of all we inherit the power of having a true concurrent functional programming with Erlang and add to that the fact that we can write a program once but have it use the native GUI for Linux, MacOSX, Windows, etc. This means if you execute the program in Linux, you will get a nice Gnome look, if you execute in MacOSX, you will net the nice Mac look, all with one single program.
wxErlang is still in an early version, but alot of documentation is provided how to use it, the only trouble one might face is actually compiling the thing.
Before you compile, make sure to have the following programs installed on your computer:
1. Erlang
2. wxGTK
3. Doxygen
Now download wxErlang and let's start.
1. tar zxvf wxe-*.tar.gz
2. cd wxe
3. Edit config.mk and change the following values:
a. PLATFORM=MACOSX
b. ERLI_VSN=`echo /usr/lib/erlang/lib/erl_interface-* | awk 'BEGIN{ FS="erl_interface-" } { print $2 }'`
c. WXCONFIG=`which wx-config`
4. cd gen
5. make xml
6. cd ..
7. make
Now if that worked, you should be able to try the example program:
1. cd etop
2. make
3. erl -pa ../ebin -run erltop start
If that worked, congratulations! You are now well on your way to learning more and writing some real applications.
wxErlang is still in an early version, but alot of documentation is provided how to use it, the only trouble one might face is actually compiling the thing.
Before you compile, make sure to have the following programs installed on your computer:
1. Erlang
2. wxGTK
3. Doxygen
Now download wxErlang and let's start.
1. tar zxvf wxe-*.tar.gz
2. cd wxe
3. Edit config.mk and change the following values:
a. PLATFORM=MACOSX
b. ERLI_VSN=`echo /usr/lib/erlang/lib/erl_interface-* | awk 'BEGIN{ FS="erl_interface-" } { print $2 }'`
c. WXCONFIG=`which wx-config`
4. cd gen
5. make xml
6. cd ..
7. make
Now if that worked, you should be able to try the example program:
1. cd etop
2. make
3. erl -pa ../ebin -run erltop start
If that worked, congratulations! You are now well on your way to learning more and writing some real applications.
Wednesday, October 11, 2006
Why you should hate everything
So, why should you hate everything?
Because you will always be right.. eventually!
We live in a world that has two major foundations(among others). The first being it is always easier to disprove something than to prove something. Second, it is better to be the person who was wrong at first, then eventually proven correct, then the person who was correct initially, then proven wrong later.
So, if you want to always be "right", you must hate everything.
Some examples.
1. Java. When Java first came out, it was all hyped up to be the next great thing, everyone was excited, etc. I myself, found it be very cumbersome, extremely boring, and of little use to me, therefore I hated it. I paid the price at first, I was ridiculed and scolded about all the benefits of Java and so on, but now finally, the tables have turned, and people see what Java really is: an excuse to kill yourself.
2. Iraq War. When the war first started, Bush had the highest approval ratings and public support was almost a complete majority. Friends and family of mine even supported the cause. I again, was against it. I just couldn't synthesize how a struggling impoverished nation would be able to do much harm to anyone else besides itself. Well, again the tides have turn and the support for war is disappearing daily and people finally see what the war really is: an excuse to kill yourself.
3. Science. Every day new discoveries are made that prove old discoveries to be untrue or not useful, from the orbit of planets to atomic bombs, we have been wrong several times in the past to get to where we are today. People now realize what scientific exploration and research really is: an excuse to kill yourself.
I could go on and on with many other examples, but the point sticks, almost everything you know will be hated one way or another, it is just natural progression. There is a 99.9% chance that if you hate something now in the face of the majority adverse opinion, you will eventually be the one who is proven correct, and all of them incorrect, how great is that!
Some things you should immediately start hating.
1. String theory
2. Linux
3. People
Because you will always be right.. eventually!
We live in a world that has two major foundations(among others). The first being it is always easier to disprove something than to prove something. Second, it is better to be the person who was wrong at first, then eventually proven correct, then the person who was correct initially, then proven wrong later.
So, if you want to always be "right", you must hate everything.
Some examples.
1. Java. When Java first came out, it was all hyped up to be the next great thing, everyone was excited, etc. I myself, found it be very cumbersome, extremely boring, and of little use to me, therefore I hated it. I paid the price at first, I was ridiculed and scolded about all the benefits of Java and so on, but now finally, the tables have turned, and people see what Java really is: an excuse to kill yourself.
2. Iraq War. When the war first started, Bush had the highest approval ratings and public support was almost a complete majority. Friends and family of mine even supported the cause. I again, was against it. I just couldn't synthesize how a struggling impoverished nation would be able to do much harm to anyone else besides itself. Well, again the tides have turn and the support for war is disappearing daily and people finally see what the war really is: an excuse to kill yourself.
3. Science. Every day new discoveries are made that prove old discoveries to be untrue or not useful, from the orbit of planets to atomic bombs, we have been wrong several times in the past to get to where we are today. People now realize what scientific exploration and research really is: an excuse to kill yourself.
I could go on and on with many other examples, but the point sticks, almost everything you know will be hated one way or another, it is just natural progression. There is a 99.9% chance that if you hate something now in the face of the majority adverse opinion, you will eventually be the one who is proven correct, and all of them incorrect, how great is that!
Some things you should immediately start hating.
1. String theory
2. Linux
3. People
Tuesday, October 03, 2006
Oct 3rd: Day Against DRM!
Today is the official "Day Against DRM"!
If you are in Chicago today, we could sure use your help! For information, please goto: http://www.chicagolug.org/Drm
Some things that we could really use help with are:
1. People to wear the Biohazard suits
2. People to hand out materials and educate
3. People to take pictures, blog, create editorial materials, etc.
It is important that we not only get the word out, but that we document this event. If you take any pictures, please upload them to flickr, with the following tags: defectivebydesign, drm, apple, chicago, ipod, itunes, nodrm, antidrm. Also, feel free to add them to the DefectiveByDesign group.
If you can't make it, you can always print out the following materials:
Anti-DRM Sign
Anti-DRM Literature
and hand them out to everyone you know!
Most of all, have a great day, and just try to educate people. Once people know what DRM is, they most surely won't like it.
If you are in Chicago today, we could sure use your help! For information, please goto: http://www.chicagolug.org/Drm
Some things that we could really use help with are:
1. People to wear the Biohazard suits
2. People to hand out materials and educate
3. People to take pictures, blog, create editorial materials, etc.
It is important that we not only get the word out, but that we document this event. If you take any pictures, please upload them to flickr, with the following tags: defectivebydesign, drm, apple, chicago, ipod, itunes, nodrm, antidrm. Also, feel free to add them to the DefectiveByDesign group.
If you can't make it, you can always print out the following materials:
Anti-DRM Sign
Anti-DRM Literature
and hand them out to everyone you know!
Most of all, have a great day, and just try to educate people. Once people know what DRM is, they most surely won't like it.
Monday, June 19, 2006
Language of the week: Haskell
Tristan Sloughter and I decided that this summer we would try learning a language each week in order to expand our knowledge of different programming languages. Our intent is to learn the lanuage well enough in order to do a simple to moderate program in the language. While I won't be able to go into detail about each language in this blog, I would like to highlight some key points of the language.
For the first language, we chose Haskell. I had used Haskell before, but it had been a long time. I had also just learned Ocaml from CS440, which shares some similarities to Haskell. For our project we decided to write the LZW algorithm, which is a simple text compression algorithm.
Haskell is well suited for this task, as the algorithm is a straight sequential process on the text, and since Haskell is a functional language, it allows for an easy implementation. The code is as follows.
The first thing we need to do is create table. Basically this is just defining what table is.
> type LZWItem = (Int, String)
> type LZWTable = [LZWItem]
After that we just need to create a table instance
> lzwTable :: LZWTable
> lzwTable = []
For the main implementation I broke the code up into 4 parts.
1. encString: main function that processes the string and takes care of the table
> encString :: String -> LZWTable -> String -> [Int]
> encString [] [] = []
> encString (k:ks) (w:ws)
> | inTable lzwTable ((w:ws)++(k:[])) = encString ks lzwTable ((w:ws)++(k:[]))
> | otherwise = addCode lzwTable ((w:k:[])++ks) : encString ks lzwTable (k:[])
Here we simply take a string as input, and process it character by character according to the LZW algorithm. If it is in the table, we continue by getting one more character, otherwise we add the string to the table.
2. inTable: this is just a little helper functiong for encString to check if the string is in the table
> inTable :: LZWTable -> String -> Bool
> inTable table str = [ tCode | (tCode,tStr)<-table, tStr==str] /= []
3. addCode: adds code to the table for a new substring > addCode :: LZWTable -> String -> Int
> addCode table (x:xs)
> | table ++ [(length(table)+1,x:xs)] /= [] = getCode table (take (length (x:xs)-1) (x:xs))
We add the new code, while getting the code for the previous string per the LZW algorithm.
4. getCode: gets the code from the table for a previous string in the table
> getCode :: LZWTable -> String -> Int
> getCode table str = head [ tCode | (tCode,tStr)<-table, tStr==str]
This simply just looks up the code from the table.
As you can see the implementation is very straightforward, relatively easy to understand, and compact. Doing this in any other(non-functional) language like C would definitely take a lot more code.
I am very happy with Haskell, as everything seems very intuitive and logical. When programming with it, you have alot of "Duh, that is so easy and simple" moments that you don't get with other languages.
When comparing Haskell with the other functional language I knew before this, Ocaml, I would have to say Haskell is better. To me, Haskell just has a better feel to it and seems to flow a little better than Ocaml. Either language is great though compared to C/C++, Java, Perl, etc.
One other cool trick I would like to quickly add about Haskell is infinite lists. For example, here is how you generate a list of every integer:
> numsFrom n = n : numsFrom (n+1)
If you are looking for a good place to start, I recommend the book, "Haskell: The Craft of Functional Programming". It is great at going through the key concepts of Haskell and showing you great examples of usage that can help you solve almost any problem.
For the curious, our next language is going to be Erlang.
For the first language, we chose Haskell. I had used Haskell before, but it had been a long time. I had also just learned Ocaml from CS440, which shares some similarities to Haskell. For our project we decided to write the LZW algorithm, which is a simple text compression algorithm.
Haskell is well suited for this task, as the algorithm is a straight sequential process on the text, and since Haskell is a functional language, it allows for an easy implementation. The code is as follows.
The first thing we need to do is create table. Basically this is just defining what table is.
> type LZWItem = (Int, String)
> type LZWTable = [LZWItem]
After that we just need to create a table instance
> lzwTable :: LZWTable
> lzwTable = []
For the main implementation I broke the code up into 4 parts.
1. encString: main function that processes the string and takes care of the table
> encString :: String -> LZWTable -> String -> [Int]
> encString [] [] = []
> encString (k:ks) (w:ws)
> | inTable lzwTable ((w:ws)++(k:[])) = encString ks lzwTable ((w:ws)++(k:[]))
> | otherwise = addCode lzwTable ((w:k:[])++ks) : encString ks lzwTable (k:[])
Here we simply take a string as input, and process it character by character according to the LZW algorithm. If it is in the table, we continue by getting one more character, otherwise we add the string to the table.
2. inTable: this is just a little helper functiong for encString to check if the string is in the table
> inTable :: LZWTable -> String -> Bool
> inTable table str = [ tCode | (tCode,tStr)<-table, tStr==str] /= []
3. addCode: adds code to the table for a new substring > addCode :: LZWTable -> String -> Int
> addCode table (x:xs)
> | table ++ [(length(table)+1,x:xs)] /= [] = getCode table (take (length (x:xs)-1) (x:xs))
We add the new code, while getting the code for the previous string per the LZW algorithm.
4. getCode: gets the code from the table for a previous string in the table
> getCode :: LZWTable -> String -> Int
> getCode table str = head [ tCode | (tCode,tStr)<-table, tStr==str]
This simply just looks up the code from the table.
As you can see the implementation is very straightforward, relatively easy to understand, and compact. Doing this in any other(non-functional) language like C would definitely take a lot more code.
I am very happy with Haskell, as everything seems very intuitive and logical. When programming with it, you have alot of "Duh, that is so easy and simple" moments that you don't get with other languages.
When comparing Haskell with the other functional language I knew before this, Ocaml, I would have to say Haskell is better. To me, Haskell just has a better feel to it and seems to flow a little better than Ocaml. Either language is great though compared to C/C++, Java, Perl, etc.
One other cool trick I would like to quickly add about Haskell is infinite lists. For example, here is how you generate a list of every integer:
> numsFrom n = n : numsFrom (n+1)
If you are looking for a good place to start, I recommend the book, "Haskell: The Craft of Functional Programming". It is great at going through the key concepts of Haskell and showing you great examples of usage that can help you solve almost any problem.
For the curious, our next language is going to be Erlang.
Sunday, May 14, 2006
Why I choose Windowmaker
For a very long time, I used Linux, just because it wasn't Windows. There were two things that made me actually enjoy Linux, so much so, that I feel deprived when I can't use a Linux machine(such as at work).
What were those two things? The first was Gentoo. I won't go into a rant about which distro is best, but Gentoo has worked for me very well.
The second reason, was Windowmaker. I had tried many other desktops, never thinking about Windowmaker, since it looks so ugly and useless. Finally, after getting tired of using Gnome and KDE and using g-this and k-that type of apps, I gave Windowmaker a try.
I was completely astonished. My productivity increased almost instantly. The speed in which you can switch desktops and maneuver to different apps all with just the middle button is a reason to use Windowmaker in of itself. I also enjoy the right click menu. Instead of having this fancy start menu and everything else that clogs most desktops, I have the full desktop to myself, and apps are only a right-click away.
I know I might not have the fanciest, latest gizmos like transparency, but is your amnesia really so bad that you forget what your background looks like behind your terminal?
Give Windowmaker a try, you may just like it.
What were those two things? The first was Gentoo. I won't go into a rant about which distro is best, but Gentoo has worked for me very well.
The second reason, was Windowmaker. I had tried many other desktops, never thinking about Windowmaker, since it looks so ugly and useless. Finally, after getting tired of using Gnome and KDE and using g-this and k-that type of apps, I gave Windowmaker a try.
I was completely astonished. My productivity increased almost instantly. The speed in which you can switch desktops and maneuver to different apps all with just the middle button is a reason to use Windowmaker in of itself. I also enjoy the right click menu. Instead of having this fancy start menu and everything else that clogs most desktops, I have the full desktop to myself, and apps are only a right-click away.
I know I might not have the fanciest, latest gizmos like transparency, but is your amnesia really so bad that you forget what your background looks like behind your terminal?
Give Windowmaker a try, you may just like it.
Saturday, May 06, 2006
Quantum Questions
As I read through books and articles about quantum physics, I have come up with a few questions over time that I still don't have a clear answer to. Maybe some other people do.
Here they are:
1. If the universe is made of symmetric particles, is it made of symmetric properties in all respects?
2. If there is a quantum universe(maybe ours), is it constant? Is it deterministic?
3. In general terms, could we ourselves be considered quantum particles to objects relatively as large as we are to quantum matter?
4. Do quantum particles always need a reason to reveal/express themselves(such as when they are measured)?
5. Strictly speaking, can information travel by other means besides waves or entanglement?
6. How does quantum matter store information, and is the type of information it can store limited?
Let me know your thoughts.
Here they are:
1. If the universe is made of symmetric particles, is it made of symmetric properties in all respects?
2. If there is a quantum universe(maybe ours), is it constant? Is it deterministic?
3. In general terms, could we ourselves be considered quantum particles to objects relatively as large as we are to quantum matter?
4. Do quantum particles always need a reason to reveal/express themselves(such as when they are measured)?
5. Strictly speaking, can information travel by other means besides waves or entanglement?
6. How does quantum matter store information, and is the type of information it can store limited?
Let me know your thoughts.
Drastic Actions
This is my first post. I have always sworn off blogs for many reasons. If you are one of those people who have yet to understand blogs, I sympathize with you. So why am I doing this? I basically want to see what the hype is about, and to see just for sure whether or not it is worth it or not. This blog will be a mixture of Linux, political things, and ideas I have for projects and research. I apologize in advance for what a bore this blog may be.
Subscribe to:
Posts (Atom)