tag:blogger.com,1999:blog-60527191724426021782024-03-19T04:14:22.093-07:00penguinboy08Technical adventures, including Linux, CSS, web development, and programming. All from the point of view of a student living in a Australia.PenguinBoyhttp://www.blogger.com/profile/16181076196573345436noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6052719172442602178.post-58406181182648956792008-04-28T19:28:00.000-07:002008-04-29T17:53:41.077-07:00Key - Arcade RevisitedJust 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.<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid0EZ270AhlTa3GL5sn_ak7n1FvZ39COPCRBrNx8vEKiwMsClziWWbJu358S1Md0FJ89xzVE1guO57Y-ELnDXUF6suyWxGJlk2IicLj0NhjdzKb3xd92ps71i-_PPAPiAT6e2_Kl87G0_D/s1600-h/keymore.PNG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid0EZ270AhlTa3GL5sn_ak7n1FvZ39COPCRBrNx8vEKiwMsClziWWbJu358S1Md0FJ89xzVE1guO57Y-ELnDXUF6suyWxGJlk2IicLj0NhjdzKb3xd92ps71i-_PPAPiAT6e2_Kl87G0_D/s320/keymore.PNG" alt="" id="BLOGGER_PHOTO_ID_5194832668408225490" border="0" /></a>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.<br /><br /><br />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!<br /><br />The homepage is located here: <a href="http://boganproductions.com/key">http://boganproductions.com/key</a><br /><br /><div style="text-align: center;"><a href="http://www.boganproductions.com/key/Key.zip">Click here to download now!</a><br /><br /><div style="text-align: left;"><br />Also, if you're interested in getting the source-code, or just having a chat, email me at raynerw@optusnet.com.au<br /></div></div>PenguinBoyhttp://www.blogger.com/profile/16181076196573345436noreply@blogger.com0tag:blogger.com,1999:blog-6052719172442602178.post-12391181278978786402008-04-10T16:08:00.000-07:002008-04-10T16:41:52.722-07:00Dear Digg Community: Linux != UbuntuDear Digg,<br /><br />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.<br /><br />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.<br /><br />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...<br /><br />Yours truly,<br />PenguinBoyPenguinBoyhttp://www.blogger.com/profile/16181076196573345436noreply@blogger.com0tag:blogger.com,1999:blog-6052719172442602178.post-24251900376799588182008-04-04T17:23:00.000-07:002008-04-04T18:24:06.703-07:00The Noobs Guide to Bash-Scripting - Part 3Welcome 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:<br /><div style="text-align: center;"><a href="http://penguinboy08.blogspot.com/2008/04/noobs-guide-to-bash-scripting-part-1.html">Bash scripting - Part 1</a><br /><a href="http://penguinboy08.blogspot.com/2008/04/noobs-guide-to-bash-scripting-part-2.html">Bash scripting - Part 2</a><br /></div><br />In this tutorial, we will cover:<br /><ul><li>"For" loops</li></ul><br /><div style="text-align: center;"><span style="font-weight: bold;">The For Loop</span><br /><br /><div style="text-align: left;">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.<br /><br />This is what we have made so far:<br /><blockquote><span style="font-family: courier new;">#!/bin/bash</span><span style="font-family: courier new;"><br />echo "//Written By $USER" >> $1</span></blockquote>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.<br /><br />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 "<span style="font-family: courier new;">*</span>" (asterisks) of course!<br /><br />We want to be able to run the script like this:<br /><span style="font-family: courier new;"><blockquote>./tag_script example_directory/*</blockquote></span>We covered the argument variables last tutorial, but there is another argument variable that I didn't mention; "<span style="font-family: courier new;">$@</span>". 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.<br /><br />A FOR loop performs the same action on all the elements inside a variable. It's standard form is this:<br /><span style="font-family: courier new;"></span><blockquote><span style="font-family: courier new;">for FILE in "$@"; do</span><br /><span style="font-family: courier new;">**YOUR CODE HERE**</span><br /><span style="font-family: courier new;">done</span></blockquote>A quick breakdown:<br /><ul><li>As I explained before, $@ is our variable that contains many elements</li><li>The code contained inside the FOR loop will be performed for each of the elements within "$@"</li><li>FILE is a variable. At the beginning of each cycle through the loop, it will equal the next element in "$@"</li></ul><br />An Example:<br /><br />$@ = "file1","file2","file3"<br /><br /><blockquote><span style="font-family: courier new;">#!/bin/bash<br /></span><span style="font-family: courier new;">for FILE in "$@"; do</span><br /> <span style="font-family: courier new;">echo $FILE</span><br /> <span style="font-family: courier new;">done</span></blockquote>The result of this script would be:<br /><blockquote style="font-family: courier new;">file1<br />file2<br />file3</blockquote>Notice, the code contained within the FOR loop was performed on each element of <span style="font-family: courier new;">$@</span>. Now it's just a simple matter of applying this in our tagging script.<br /><span style="font-family: courier new;"></span><blockquote><span style="font-family: courier new;">#!/bin/bash</span><br /><span style="font-family: courier new;">for FILE in "$@"; do</span><br /><span style="font-family: courier new;">echo "//Made by $USER" >> "$FILE"</span><br /><span style="font-family: courier new;">done</span></blockquote><br />Then we just have to call the script with this:<br /><span style="font-family: courier new;"><blockquote>./tag_script target_directory/*</blockquote></span><br />IMPORTANT: The script will not work at all unless you include the "<span style="font-family: courier new;">*</span>"<br /><br /><br />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.<br /></div></div>PenguinBoyhttp://www.blogger.com/profile/16181076196573345436noreply@blogger.com0tag:blogger.com,1999:blog-6052719172442602178.post-51033366093940258992008-04-03T16:15:00.000-07:002008-04-03T17:43:59.646-07:00The Noobs Guide to Bash-Scripting - Part 2For those who don't know, this is a continuation of a series, the first of which is <a href="http://penguinboy08.blogspot.com/2008/04/noobs-guide-to-bash-scripting-part-1.html">located here.</a><br /><br />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.<br /><br /><br /><div style="text-align: center;"><span style="font-weight: bold;">The Situation</span><br /></div><br />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.<br /><br /><br /><div style="text-align: center;"><span style="font-weight: bold;">Arguments + Variables</span><br /></div><br />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:<br /><span style="font-family:courier new;"></span><blockquote><span style="font-family:courier new;">./example_script argument1 argument2</span></blockquote>You can have as many arguments as you want. You can also use "<span style="font-family:courier new;">*</span>" 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.<br /><br />Whoa! Timeout! What the fart is a variable?<br /><br />Well, a variable is basically a value (<span style="font-family:courier new;">1</span>, "<span style="font-family:courier new;">three</span>", "<span style="font-family:courier new;">foobar</span>", <span style="font-family:courier new;">1.43</span>), that is represented by a name. In bash scripting, you can tell something is a variable by the fact it has a <span style="font-family:courier new;">$</span> in front of the rest of the name. Variables can be created very easily:<br /><span style="font-family:courier new;"></span><blockquote><span style="font-family:courier new;">example_variable="example_value"</span><br /><span style="font-family:courier new;">echo $example_variable<br /></span></blockquote>The output of the above script would be "example_value". Notice how when we created the variable, we didn't include the <span style="font-family:courier new;">$</span> at the beginning. This is very important, don't forget it!<br /><br />Continuing on... whenever your script is started with arguments, variables are automatically created for you! They are:<span style="font-family:courier new;"> $1, $2, $3, $4</span> ... etc. There will only be as many variables as there arguments. Lets put this to use! Create a script with the following:<br /><span style="font-family:courier new;"></span><blockquote><span style="font-family:courier new;">#!/bin/bash</span><br /><span style="font-family:courier new;"><br />echo $1</span></blockquote>Then run it like this:<br /><span style="font-family:courier new;"><blockquote>./script_name example_argument</blockquote><br /></span>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.<br /><span style="font-family:courier new;"></span><blockquote><span style="font-family:courier new;">#!/bin/bash</span><br /><span style="font-family:courier new;"><br />echo "//Written By A Programmer" >> $1</span></blockquote><br />So now we can tag that message on the end of each file with one command...<br /><span style="font-family:courier new;"></span><blockquote><span style="font-family:courier new;">./tagging_script example_file</span></blockquote><br />So far it's looking good! But there are still a few problems,<br /><ul><li>We still need to run this command for every single file... (This will be fixed in our next tutorial)<br /></li><li>If we give this script to our friends, they will have to change the script so that their name is there</li></ul>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 "<span style="font-family:courier new;">$</span>" and then pressing [TAB] twice. This will list all the available variables, but we're only looking for one... "<span style="font-family:courier new;">$USER</span>". This is the current user running the program, we can easily put this into our script.<br /><blockquote style="font-family: courier new;">#!/bin/bash<br /> echo "//Written By $USER" >> $1</blockquote><br />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!<br /><br /><br />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!PenguinBoyhttp://www.blogger.com/profile/16181076196573345436noreply@blogger.com0tag:blogger.com,1999:blog-6052719172442602178.post-32650868408300572972008-04-02T18:27:00.000-07:002008-04-03T17:39:15.037-07:00The Noobs Guide to Bash-Scripting - Part 1So 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!<br /><br /><br /><div style="text-align: center;"><span style="font-weight: bold;">Setup</span><br /></div><br />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<span style="font-weight: bold;"> </span><span>create a folder called</span><span style="font-weight: bold;"> "<span style="font-style: italic;font-family:courier new;" >bash</span>"</span> inside your home directory, this will be where all your bash scripts are kept. Then <span>create a folder called </span><span style="font-weight: bold;">"<span style="font-style: italic;font-family:courier new;" >helloworld</span></span>" inside your bash folder. Now<span style="font-weight: bold;"> </span><span>create a file called</span><span style="font-weight: bold;"> "<span style="font-style: italic;font-family:courier new;" >hello_world</span>"</span> inside your "<span style="font-style: italic; font-weight: bold;font-family:courier new;" >helloworld</span>" folder.<br /><br />You should end up with a folder structure like this:<br /><br /><span style="font-family:courier new;">---- bash<br /></span><span style="font-family:courier new;">-------- helloworld<br /></span><span style="font-family:courier new;">------------ hello_world</span><br /><br /><br />Now, open up <span style="font-style: italic;">hello_world</span> 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: <blockquote><span style="font-family:courier new;">#!/bin/bash</span></blockquote><br />This is location of your bash program. Nothing complicated, just make sure it's the first line.<br /><br /><br /><div style="text-align: center;"><span style="font-weight: bold;">The Basics</span><br /><br /><div style="text-align: left;">The rest of the bash script consists of commands that you would normally be able to type in a command line.<br /><br />eg. Typing <span style="font-style: italic;">ls </span>in command line will get the same results as running a bash script that contained:<br /><blockquote style="font-family: courier new;">#!/bin/bash<br />ls</blockquote><br />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 <span style="font-family:courier new;">/home/user</span> , then the script would print the contents of <span style="font-family:courier new;">/home/user</span> in your command line.<br /><br />Back to our<span style="font-family:courier new;"> hello_world </span>script; we want this script to output a message onto the screen. One suitable command for this is <span style="font-family:courier new;">echo</span>. The usage of<span style="font-family:courier new;"> echo </span>is pretty simple:<br /><blockquote style="font-family: courier new;">echo "Your message here"</blockquote>So, lets implement this in our <span style="font-family:courier new;">hello_world</span> script. Here is the final script:<br /><blockquote style="font-family: courier new;">#!/bin/bash<br />echo "Hello World!"</blockquote>For more options on how to use echo, check out it's man page:<br /><span style="font-family:courier new;"></span><blockquote><span style="font-family:courier new;">man echo</span></blockquote><br /><br /><div style="text-align: center;"><span style="font-weight: bold;">Finishing Up: Running the script</span><br /><br /><div style="text-align: left;"><br /></div></div>Almost there! Now all we need to is make sure the <span style="font-family:courier new;">hello_world</span> file is executable. We can do this with one command while in the <span style="font-family:courier new;">helloworld</span> directory.<br /><span style="font-family:courier new;"><blockquote>chmod +x hello_world</blockquote></span>Then it's a simple matter of running the script:<br /><span style="font-family:courier new;"><blockquote>./hello_world<br /></blockquote></span>Alternatively, you can run the script without having to chmod it:<br /><span style="font-family:courier new;"><blockquote>sh hello_world</blockquote></span><br /><br />Hopefully our script ran successfully, if not, go back and check that your code is correct.<br /><br />Alright, now that our script is fully functional, we want to be able to run it without having to go into the <span style="font-family:courier new;">.../bash/helloworld/</span> directory. This is relatively simple, all you need to do is copy your script into the <span style="font-family:courier new;">/usr/local/bin</span> directory. On most systems, you will need root access.<br /><br />Once you've copied the script, then just have to enter <span style="font-family:courier new;">hello_world</span> into your command line to run the script.<br /><br /><br /><br />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!<br /></div></div>PenguinBoyhttp://www.blogger.com/profile/16181076196573345436noreply@blogger.com0tag:blogger.com,1999:blog-6052719172442602178.post-25600627597064857892008-04-02T16:43:00.000-07:002008-04-02T22:58:20.994-07:00Songbird = AmazingIf 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 <a href="http://www.songbirdnest.com/">HERE.</a><span style="display: block;" id="formatbar_Buttons"><span class="on down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"><br />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.<br /><br />Some of the features Songbird includes:</span></span><ul><li>Out-of-the-box iPod support, for ALL OS's</li><li><span style="font-weight: bold;">Tabbed browsing</span> (In a music player, wtf?)<span style="font-weight: bold;"><br /></span></li><li>Recursive folder scanning, for easier importing of music</li><li>Regular updates, much like Firefox.</li></ul><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-RwP83pK4MGukArWPHpB0aBE1-2qEgzKIKGpXpx4D7JfPGYIG1PtrKZN6DTrabgiTK93wiia7TWEQjeM4WFQAD7FMupbujgNdbz0FDbmt1knfJzFMmNkQpJ8UIEt2xIsYV5yvaI1e93BW/s1600-h/songbird.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-RwP83pK4MGukArWPHpB0aBE1-2qEgzKIKGpXpx4D7JfPGYIG1PtrKZN6DTrabgiTK93wiia7TWEQjeM4WFQAD7FMupbujgNdbz0FDbmt1knfJzFMmNkQpJ8UIEt2xIsYV5yvaI1e93BW/s320/songbird.png" alt="" id="BLOGGER_PHOTO_ID_5184803331486823282" border="0" /></a><br />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.<br /><br />For Ubuntu: <blockquote>sudo apt-get install gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly gstreamer0.10-ffmpeg gstreamer0.10-fluendo-mp3</blockquote>For Gentoo: <blockquote>emerge -av gstreamer gst-plugins-base gst-plugins-xvideo gst-plugins-x gst-plugins-gconf gst-plugins-gnomevfs gst-plugins-alsa</blockquote><div style="text-align: center;">AND<br /></div><blockquote>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</blockquote><br />So what are you what are you waiting for?? <a href="http://www.songbirdnest.com/">GET IT NOW</a>!!!PenguinBoyhttp://www.blogger.com/profile/16181076196573345436noreply@blogger.com0tag:blogger.com,1999:blog-6052719172442602178.post-890862844608613382008-04-02T16:14:00.000-07:002008-04-02T16:38:13.137-07:00Ubuntu -> GentooAs my exploration of GNU/Linux continues, I've decided to move from perhaps the most user-friendly distros (<a href="http://www.ubuntu.com/">http://www.ubuntu.com</a>) to one of the "hardcore" distros, Gentoo (<a href="http://gentoo.org/">http://www.gentoo.org</a>).<br /><br />Now, many Ubuntu users will be perplexed as to why I would move away from the most supported linux distro....<br /><br />Because it's fun.<br /><br />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. (<a href="http://www.dreamlinux.com.br/">http://www.dreamlinux.com.br</a>, <a href="http://www.sabayonlinux.org/">http://www.sabayonlinux.org</a>, <a href="http://www.damnsmalllinux.org/">http://www.damnsmalllinux.org</a>)<br /><br />Anyway, if you're interested in some Gentoo fun, check out gentoo.org!<br /><br />Follow the handbook installation process for a flawless install (<a href="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml">Gentoo Handbook</a>)<span style="display: block;" id="formatbar_Buttons"><span class="on down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"></span></span>PenguinBoyhttp://www.blogger.com/profile/16181076196573345436noreply@blogger.com0