Category Archives: Scripts

New Firefox Addon Found, Fixes Drudge Report Refresh Roil

I am a news junkie, I love to read the news from many sources and (try to) keep up with what is going on in the world.  One of the sites I frequent a lot is the Drudge Report, and anyone who has been there will know that (to me anyway) one really annoying thing about that site is the constant page refreshing.  Maybe this is done in an attempt to load more banner ads or something, but it gets on my nerves when I keep losing my place as I am reading articles.

So, in my attempt to find an easy way to stop the Drudge Report website from refreshing every second or so (OK, maybe not EVERY second), I came across a nifty little plugin for Firefox that allows you to blacklist websites and thus stop them from running scripts.  In this case that also meant that Drudge no longer refreshes while I am reading the news.  It’s a lot like the NoScript plugin that we have talked about before, except that instead of deny all and permit by exception, this one is the other way around.  Everything is white listed by default and you blacklist sites that you don’t want to run scripts.  It works great for me, and I have found it to be quite useful.  I have added it to the Must Have Firefox Extensions page in the Library, go check it out and while you are there, see what other ones we talk about.  Enjoy!

Solarum’s Open Source Project – nix32

I thought I would post some information about a project that I started a few months ago called nix32.  It’s hosted on SourceForge for the most part, with a handy website that I host myself mainly because it’s just easier to manage that way.  The basic goal of this project is to create native command line tools for Windows that operate much like the commands that we know and love from Linux and UNIX.  Things like ls, mv, cp, df and so on.  I have become so used to, comfortable with and productive with the UNIX/Linux command line environment, that when I have to leave it behind on Windows, it’s pretty tough.  Not just changing from what I am used to, but also because I think the command line of a UNIX/Linux server is much more powerful and flexible than the Windows command line, even including the power shell.

I have been working on the more popular commands, and I have a few basics out now with basic functionality.  I hope to have more and better (improved) tools in the future.  I am writing everything in PERL and then compiling each one on Windows as a standalone exe using tools from ActiveState, and so far, they run very nicely.  It’s all completely open source, you can download the PERL scripts as well as the executable files if you want to take a look or help improve them.

Now, I know you can get similar results with other projects and products out there, CYGWIN comes to mind first.  However, that’s a whole separate shell and almost a little mini-Linux setup in and of itself, especially looking at the directory structure after it’s installed.  Here with the nix32 project I wanted to have native Windows executables that you can stick in your path somewhere and call right from the Windows Command Prompt, without ever leaving the Windows environment and without having to install anything.  So far that is exactly what we have, just copy the files somewhere, make sure it’s within or added to your PATH variable, and you are good to go!

So check it out, see what you think, spread the word and maybe even help out a bit and crunch a little code too.  Do whatever you feel and keep both feet on the wheel … or, keyboard maybe.  🙂

Awesome Source Code Library

(Click to enlarge)

OK, boys and girls, I have a really cool treat for you.  For a long time now I have been looking for the right application to use as a source code library.  I say application because I have been trying to be open minded about what to use.  I have tried Wiki’s (which actually aren’t too bad), note taking programs, and a great many other tools, including a couple that were specifically written to be source code libraries … but in the end fell quite short of my expectations.  Also, when I say source code library, I am not and have not been looking for tons of canned code to take advantage of, that’s the problem I have now, 20+ years in IT and I already have tons of code, I just need a way to store it, sort it, search it, export it, back it up, and anything else I can think of!  I’d like to note too that in addition to all of the other features I may list here, this tool does a superb job at syntax highlighting as well.

Let me digress for a moment to mention a site called Donation Coder (www.donationcoder.com), these guys are great!  Lots of free software from some really talented developers.  There are some apps there that beat their commercial competition by a country mile, hands down.  That’s one reason why I like to hang out there, in the forums for example, these guys write software because they enjoy writing software.  Therefore they create some wicked cool stuff.

How does this pertain to the issue at hand?  Well, it was in the forums there that I ran across a thread where people were talking about their own search for a source code library much like my own search.  I found one post among others recommending different things that mentioned a free tool called “Developer’s Tips & Tricks (DTT)” from Freesoftland.  I had never heard of this group before, but I liked what I had seen posted in the Donation Coder forums, plus I really liked what I saw when reading up on their DTT tool.

Continue reading Awesome Source Code Library

MySQL Database Backup Script

Here we go folks, I thought I would share a handy little script with you that I use to backup all of the databases on a particular Linux/UNIX server.  I do this by getting a list of the databases, and then using mysqldump to dump them all to a text file.  This seems to be the best way (short of replication) to get good clean backups of the data.  Toss it into a cron job and you can have it done automagically.  There isn’t anything yet to rotate files, but I might add that later.  Also, I am going to try and rewrite this in PERL so our Windows (and other OS’s that don’t have a shell like Bash) brethren can run this script as well.  For now though, it’s written for Bash but almost any shell would work I think.

OK, onto the script.  Continue reading MySQL Database Backup Script

PERL Tip For Data In Arrays

Recently I was working on a script for log reporting.  You know, one of those handy little guys that send you some info every day helping to make sure you keep up with whatever it is that you don’t want to forget about.  Well, some of the data was in a plain old text file, and there is nothing wrong with that.  It’s easy to simply cat the file and pipe it through mailx or mutt, no fuss, no muss.

Continue reading PERL Tip For Data In Arrays

PERL Round Function

Hey all your PERL junkies like me, I have a present for you. Anyone that has done any coding at all other PERL will know (and miss) the round function that most other languages have built in. For those that may not know, the round function lets you do just that, round a number to the specified digit. So, instead of having to use 3.14159265 as an answer for a particular equation, you could round it to 3.14. Nice, huh?

Well, here is a neato little round function that you can drop into your PERL scripts and call to actually round numbers instead of cutting them off with ceil or cut. Check it out:

sub round {
  my($number) = shift;
  return int($number + .5 * ($number <=> 0));
}

There you go!

**Update**
Thanks to Thierry H. for adding a little mod to the round function allowing you to specify the number of decimals to print. Here is the modified function:

sub round {
  my $number = shift || 0;
  my $dec = 10 ** (shift || 0);
  return int( $dec * $number + .5 * ($number <=> 0)) / $dec;
}

You would call it by giving not only the number to round, but how many numbers to show on the right side of the decimal. It will look like so:

$result = round(123.4567,3);

This should return 123.457 (the 6 in the third slot gets rounded to 7). There ya go, thanks for the mod Thierry! You can check out Thierry’s site here.