Monday, April 28, 2008

Key - Arcade Revisited

Just taking some time out to spread the word of my arcade game, "Key". It's been a while since it was finished, but I haven't really released it to the public.Key is basic arcade game that depends on the player's reaction time and for-thought. It's fairly hard to get even close to the high scores, but you skill will improve exponentially once you start playing. It's a great game for people who just want to have fun, but there is also room for the people who want the glory of the #1 spot.


Basically, Key is a great little time waster. If you're feeling bored, or are just looking for some cheap thrills, give it a go!

The homepage is located here: http://boganproductions.com/key

Click here to download now!


Also, if you're interested in getting the source-code, or just having a chat, email me at raynerw@optusnet.com.au

Thursday, April 10, 2008

Dear Digg Community: Linux != Ubuntu

Dear Digg,

In some ways, you are much like a small child. You're not afraid to tell the truth, not afraid to say it like it is. This is, and should be appreciate, for this is what gives our community the charm that it has. However... I think this you may have a small case of ADHD. You are amazed by shiny new things, and I think you spend a bit too much time staring at them. Logic seems like an ideal thing, but is sometimes hard for this you to grasp. You prefers to follow others, much like a lemming. I'm sure Mac is a really cool kid (on the outside at least), and I know that Vista is an asshole. But... I fear that you may one day have a lapse of judgment and take the candy from the metaphorical stranger, this can only result a lifetime of sleepless nights and much therapy.

Ok... maybe that was a bit far. I'm not saying Ubuntu is a pedophile, social suicide is usual not my thing. But people, come on! Ubuntu is a subset of Linux, it's one of many distributions! Sure it may be arguably the most user friendly to install and use, but it's not the universe. Every time I look in the Linux/Unix stories, it's always "Top 10 Reasons I Love Ubuntu", "Apps to prettify Ubuntu", "Increase your productivity in Ubuntu". Don't you understand that these applications that you're describing weren't spawned from the cesspool of apt-get?? Most linux programs are exactly that, programs for LINUX. This includes: CentOS, Debian, Fedora, Gentoo, Knoppix, Linspire, Mandriva, openSUSE, PCLinuxOS, Red Hat, Slackware, and yes... your favorite uncle, Ubuntu.

Yes, I understand, Ubuntu is a much less intimidating word than GNU/Linux. But we have to draw the line somewhere! I'm sorry digg... I don't want to fight with you... Can we just move on? I'm waiting for the next "Top 10 reasons Vista is burning in OS hell" list...

Yours truly,
PenguinBoy

Friday, April 4, 2008

The Noobs Guide to Bash-Scripting - Part 3

Welcome back! This is the third in a series of tutorials aimed at teacher beginners how to make their own bash script. The previous tutorials are located here:

In this tutorial, we will cover:
  • "For" loops

The For Loop

We're going to continue the bash script that we had made last tutorial. In our scenario we are a programmer working with a smallish team of like-minded programmers. We are about to group all the code files together in order to be review and compiled. However, we realize that we have forgotten to sign our name on our files! So we have set of to create a small bash script that would "tag" each file with the our user name.

This is what we have made so far:
#!/bin/bash
echo "//Written By $USER" >> $1
There is one outstanding problem with this though, we have to run the command for each of our code files. Depending how many files there are, this could take a while. So what need is to be able to pass all the files we want to tag, in one argument.

Lets say, for the benefit of this exercise, that all our files are in a single directory. What would you usually do in a command line if you want to perform an operation on many files? Use the "*" (asterisks) of course!

We want to be able to run the script like this:
./tag_script example_directory/*
We covered the argument variables last tutorial, but there is another argument variable that I didn't mention; "$@". This variable contains ALL of the arguments that were used, each variable is referred to as an "element". This combination of all the elements in one variable is what allows us to use the FOR loop.

A FOR loop performs the same action on all the elements inside a variable. It's standard form is this:
for FILE in "$@"; do
**YOUR CODE HERE**
done
A quick breakdown:
  • As I explained before, $@ is our variable that contains many elements
  • The code contained inside the FOR loop will be performed for each of the elements within "$@"
  • FILE is a variable. At the beginning of each cycle through the loop, it will equal the next element in "$@"

An Example:

$@ = "file1","file2","file3"

#!/bin/bash
for FILE in "$@"; do
echo $FILE
done
The result of this script would be:
file1
file2
file3
Notice, the code contained within the FOR loop was performed on each element of $@. Now it's just a simple matter of applying this in our tagging script.
#!/bin/bash
for FILE in "$@"; do
echo "//Made by $USER" >> "$FILE"
done

Then we just have to call the script with this:
./tag_script target_directory/*

IMPORTANT: The script will not work at all unless you include the "*"


Thanks for reading again, and I hope you learn something from this exercise. If you've got any questions or suggestions, don't hesitate to email me, raynerw[at]optusnet[dot]com[dot]au. Feel free to link to this site, please don't copy any material on here. Don't forget to check back later for the next tutorial: IF statements.

Thursday, April 3, 2008

The Noobs Guide to Bash-Scripting - Part 2

For those who don't know, this is a continuation of a series, the first of which is located here.

So far we've covered the very basics on how to get a script up and running. We've had it display some trivial information too! But this is hardly useful for everyday applications.


The Situation

For instance, lets say your working in a group of programmers. You are working on a large project, and your team is about to put all your files with the rest of the projects files. You suddenly realize that you forgot to put your name on each of your files! We can write up a quick script that will add a tag on the end of all of you files within a certain directory. Note: Unlike the last tutorial, I will not be telling you what your files should be called, you should be able to decide for yourself.


Arguments + Variables

To do this, we need to somehow tell the script what directory to process. This can easily be done by adding arguments on the end of the command. eg:
./example_script argument1 argument2
You can have as many arguments as you want. You can also use "*" as an argument, but we'll go into that later... Arguments can be easily accessed in the script, they are automatically assigned to a variable.

Whoa! Timeout! What the fart is a variable?

Well, a variable is basically a value (1, "three", "foobar", 1.43), that is represented by a name. In bash scripting, you can tell something is a variable by the fact it has a $ in front of the rest of the name. Variables can be created very easily:
example_variable="example_value"
echo $example_variable
The output of the above script would be "example_value". Notice how when we created the variable, we didn't include the $ at the beginning. This is very important, don't forget it!

Continuing on... whenever your script is started with arguments, variables are automatically created for you! They are: $1, $2, $3, $4 ... etc. There will only be as many variables as there arguments. Lets put this to use! Create a script with the following:
#!/bin/bash

echo $1
Then run it like this:
./script_name example_argument

The important thing about arguments, is that they can be file or directory names too! Do you see where we're going with this? We can specify a file for the script to "tag" with our name, therefore eliminating the need to open every single manually.
#!/bin/bash

echo "//Written By A Programmer" >> $1

So now we can tag that message on the end of each file with one command...
./tagging_script example_file

So far it's looking good! But there are still a few problems,
  • We still need to run this command for every single file... (This will be fixed in our next tutorial)
  • If we give this script to our friends, they will have to change the script so that their name is there
The second problem is addressed fairly easily! Along with the argument variables, there a whole bunch of other variable that accessible. You can see them by going into your console, and typing "$" and then pressing [TAB] twice. This will list all the available variables, but we're only looking for one... "$USER". This is the current user running the program, we can easily put this into our script.
#!/bin/bash
echo "//Written By $USER" >> $1

Great! Now our script is more portable! Portability is very important when it comes the script writing, or any programming in general. It takes a little more work now, but it will most likely save you lots of work later on!


This concludes the second part of our bash scripting tutorial. Next time: For loops and if statements! The fun never stops! Hope to see you here next time!

Wednesday, April 2, 2008

The Noobs Guide to Bash-Scripting - Part 1

So let's say that you want to perform tedious file management tasks but you don't want to take the time out to program something in a real language (C,C++). A bash script is the right thing for you!


Setup

Enough talking, lets get started! As always, file structure in your projects is crucial to ensure that you don't accidentally delete something. So lets create a folder called "bash" inside your home directory, this will be where all your bash scripts are kept. Then create a folder called "helloworld" inside your bash folder. Now create a file called "hello_world" inside your "helloworld" folder.

You should end up with a folder structure like this:

---- bash
-------- helloworld
------------ hello_world


Now, open up hello_world with your favorite text editor. I suggest gedit, but there are many (vim, nano, etc...). On most Linux systems, the first line of your bash script should be:
#!/bin/bash

This is location of your bash program. Nothing complicated, just make sure it's the first line.


The Basics

The rest of the bash script consists of commands that you would normally be able to type in a command line.

eg. Typing ls in command line will get the same results as running a bash script that contained:
#!/bin/bash
ls

The commands in a bash script will be run in the directory that you run the script in. So if you run the above script in /home/user , then the script would print the contents of /home/user in your command line.

Back to our hello_world script; we want this script to output a message onto the screen. One suitable command for this is echo. The usage of echo is pretty simple:
echo "Your message here"
So, lets implement this in our hello_world script. Here is the final script:
#!/bin/bash
echo "Hello World!"
For more options on how to use echo, check out it's man page:
man echo


Finishing Up: Running the script


Almost there! Now all we need to is make sure the hello_world file is executable. We can do this with one command while in the helloworld directory.
chmod +x hello_world
Then it's a simple matter of running the script:
./hello_world
Alternatively, you can run the script without having to chmod it:
sh hello_world


Hopefully our script ran successfully, if not, go back and check that your code is correct.

Alright, now that our script is fully functional, we want to be able to run it without having to go into the .../bash/helloworld/ directory. This is relatively simple, all you need to do is copy your script into the /usr/local/bin directory. On most systems, you will need root access.

Once you've copied the script, then just have to enter hello_world into your command line to run the script.



This concludes the first part of The Noobs Guide to Bash-Scripting, there will be more interesting things coming in the next part, such as conditional statements, functions and arguments. So be sure to come back soon, until then, play around with your script!

Songbird = Amazing

If haven't already heard, Songbird 0.5 was released not too long ago. Songbird is essentially an iTunes clone with a whole lot more features packed in. Check it out HERE.
Songbird was developed by Mozilla, the same people who created Firefox and Thunderbird. So already you know that it's going to be a quality program. In fact, it has a very similar UI layout to Firefox.

Some of the features Songbird includes:
  • Out-of-the-box iPod support, for ALL OS's
  • Tabbed browsing (In a music player, wtf?)
  • Recursive folder scanning, for easier importing of music
  • Regular updates, much like Firefox.

Note: On linux, you will need the GStreamer plugins, (you probably already have them). If you don't have them, you can easily install them.

For Ubuntu:
sudo apt-get install gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly gstreamer0.10-ffmpeg gstreamer0.10-fluendo-mp3
For Gentoo:
emerge -av gstreamer gst-plugins-base gst-plugins-xvideo gst-plugins-x gst-plugins-gconf gst-plugins-gnomevfs gst-plugins-alsa
AND
emerge -av gst-plugins-ugly gst-plugins-faad gst-plugins-ffmpeg gst-plugins-flac gst-plugins-lame gst-plugins-mad gst-plugins-ogg gst-plugins-vorbis gst-plugins-mpeg2dec gst-plugins-theora gst-plugins-faac

So what are you what are you waiting for?? GET IT NOW!!!

Ubuntu -> Gentoo

As my exploration of GNU/Linux continues, I've decided to move from perhaps the most user-friendly distros (http://www.ubuntu.com) to one of the "hardcore" distros, Gentoo (http://www.gentoo.org).

Now, many Ubuntu users will be perplexed as to why I would move away from the most supported linux distro....

Because it's fun.

That's right, linux started out as a hobbyists operating system, something people would develop and use for the pure enjoyment of it. While projects like Ubuntu are bringing linux closer to becoming a real option for the average desktop, most distrobutions are still very much just for fun. (http://www.dreamlinux.com.br, http://www.sabayonlinux.org, http://www.damnsmalllinux.org)

Anyway, if you're interested in some Gentoo fun, check out gentoo.org!

Follow the handbook installation process for a flawless install (Gentoo Handbook)