Tuesday, April 29, 2008

Using Perl to Improve Poor Spelling

# written by sam levine (hn darkscyon dn gmail tld com)
# this software comes with no warranty. it may blow up your computer. you have been warned.
# this code is licensed under the GPL.
# this is some random code I was playing with to better grasp regular expressions
# I will improve it at some point (comments, actually working, etc.), for now feel free to
# have fun with it if you are so inclined.
sub clean {
my $input = $_[0];
print "problem text = $input\n";
$input =~ s/(.*)/\L\1/;
$input =~ s/(.*)/\u\1/;
$input =~ s/\bliek\b/like/ig;
$input =~ s/\bpwn/defeat/ig;
$input =~ s/\bteh\b/the/ig;
$input =~ s/z(o|0)r\b/ing/ig;
$input =~ s/(!|\?)(!|\?)+/\1/ig;
$input =~ s/kthank?x+/thank you/ig;
$input =~ s/\bwit\b/with/ig;
$input =~ s/\bbiye+/bye/ig;
$input =~ s/\bomg\b/exclamation/ig;
$input =~ s/\breall+y\b/really/ig;
$input =~ s/\bu\b/you/ig;
$input =~ s/\br\b/are/ig;
#print $input;
return $input;

while (<>) {
$output = &clean($_);
print $output;


Monday, April 28, 2008

Windows (Vista or XP) is actually fine, it's the lack of good 3rd party apps that kills it for the home user

Thanks to lifehacker for putting together such a good list of 3rd party software to use on Windows:


The reason why I love Ubuntu (and Linux in general) is that you can install most of the equivalent apps with a single command line operation. This alone would keep me using Ubuntu, even if I ended up buying a Macbook Pro.

Microsoft: Stop making crappy apps and bundle the good stuff with your OS (or make it easy to install them). Small groups of hackers have made great software that they give away for free. Help out your customers and help them get it without having to be nerds.

Sunday, April 27, 2008

Perl To Blogger

# perltoblogger
# written by Sam Levine (hn darkscyon dn gmail tld com).
# this may blow up your computer. use it at your own risk.
# this code is licensed under the GPL.
# This script is designed to convert perl scripts into code that can
# be posted into
# blogger with a minimum of fuss
# it does not create full html (if it did I would call it
# perltohtml), rather it creates code within
# <pre></pre> tags that may be posted as code snippets
# on blogger (or a forum, or a mediawiki wiki, etc.)
# Useage: perltoblogger [InputFile] > OutputFile.html
# Example: perltoblogger myperlfile > myhtmlfile.html
# thanks to http://www.w3schools.com/tags/ref_entities.asp for the
# list of ASCII entities
# thanks to http://bguide.blogpost.com/2008/03/html-entities.html
# for showing me how to be less of a noob.
# thanks to everyone involed in making perl.
print "<pre>\n";
while (<>) {

print "</pre>\n";

Wednesday, April 23, 2008

a study aid for the Linux+ exam: perlreadsome (Man Pages)

While I was studying for my Linux+ exam I was unable to
find a utility to cycle through all the administrative
man pages on my computer. I wrote the script below for
this purpose.

At some point I may put it up on sourceforge (by that
time it might even work on a non-ubuntu linux computer)
, but for now I just wanted it off of my eee pc before
I blow it away and install Ubuntu 8.04 on it.

# Perl Read Some (Man Pages) version 0.01
# this script was written by sam levine (hn darkscyon dn
# gmail tld com).
# it come with NO WARRANTY at all. it is licensed
# under the GPL (Gnu Public License)
# I am a noob programmer. this may make your computer
# what this script is designed to do:
# Enable you to study man pages.
# while I was studying for my Linux+ test I read man
# pages a lot to prepare.
# doing so was a pain in the arse. I decided to write
# this script for fun,
# and hopefully to help other people prepare for the
# test (this may be helpful for
# the LPIC tests as well.

#@pages = qw[ man ls ping fdisk ifconfig ];
print "create the manlist? (press y then enter)
\n"; # this creates the list of pages to read
chomp($wait = <STDIN>);
if ( $wait eq 'y' ) {
open MANLIST, "> manlist.sav"; #
# this overwrites any file named manlist.sav in the
# same folder as the script.
select MANLIST;
print ""; #clear manlist.sav
close MANLIST;
select STDOUT;
print "cleared the manlist.sav file\n";
# user feedback is important

@input = `ls /usr/share/man/man8/`; # create an
# array with all the admin man pages
# need to determine the location of this
# and make it portable.

foreach (@input) {
# remove everything after the . in the file name
open MANLIST, ">> manlist.sav";
select MANLIST;
print; # add the page to the file
close MANLIST;
select STDOUT;
print "Just made the manlist.sav file.
Press Enter to continue\n"; # I love feedback ;)
chomp($wait = <STDIN>);

open MANLIST, "manlist.sav";

foreach $item (<MANLIST>) {
push(@pages, $item); # create an array with all
the pages in the manlist.sav file

# print "$pages[1]\n";
# print "$pages[2]\n";
# print "$pages[ -1 ]\n";

#$page = 'man';
foreach $page (@pages) {
#$maning = `man $page`;
system "man $page"; # read the man page
#print $maning;
push(@pages, $page);
# copy the first item to the last item
shift @pages; # remove the first item
print "\nCare to quit?
please press q then enter\n";
chomp($wait = <STDIN>);
if ( $wait eq 'q' )
print "saving the manlist\n";
open MANLIST, ">manlist.sav";
select MANLIST;
print ""; # clear manlist.sav
open MANLIST, ">>manlist.sav";
select MANLIST;
# recreate the manlist.sav file with the new organized list of pages
foreach $page (@pages) {
print $page;
close MANLIST;
select STDOUT;


Tuesday, April 1, 2008

Overclocking my eee pc 701

As much as I like using Ubuntu on my eee pc, I find it to be a little on the slow side when compared to the easy mode version of Xandros (their description, not mine) that the laptop ships with.

Due to this I decided to "overclock" the device back to the speed it was supposed to ship at (900mhz). Doing this will reduce your battery life and can completely destroy your eee pc, even if you do it correctly. Please don't complain if your device gets borked while doing anything mentioned in this post, this is hacky stuff.

I've had good results with the kernel module written by kiwidrew:


After following the instructions to download install the kernel module in the above link, I put together the script below to overclock the eee:

sh -c 'echo 85 24 1 > /proc/eee/fsb'
echo "FSB overclocked to 85MHz"
sleep 2
sh -c 'echo 90 24 1 > /proc/eee/fsb'
echo "FSB overclocked to 90MHz"
sleep 2
sh -c 'echo 95 24 1 > /proc/eee/fsb'
echo "FSB overclocked to 95MHz"
sleep 2
sh -c 'echo 100 24 1 > /proc/eee/fsb'
echo "FSB overclocked to 100MHz"

I named the script oc, made it executable (chmod +x) and copied it to /usr/local/bin.

I can overclock the eee by running sudo oc. I've been using it for a good month without any stability problems, so today I decided to make it start automatically.

To do so I made a link to it using the command below:

sudo ln -s /usr/local/bin/oc /etc/init.d/oc

I made it start automatically by running the command below:

sudo sysv-rc-conf --level 2 oc on

With any luck you'll have an overclocked eee that will be slightly faster than before. You should check the content of /proc/eee/fsb to make sure it's really running at 100 Mhz (the cpu speed is 9 times this, 900 mhz).

Thanks to Kiwidrew for writting an awesome kernel module!