2-Cent Tips
2-cent Tip: Perl Search Directory Function
Thomas Bonham [thomasbonham at bonhamlinux.org]
Tue, 27 May 2008 15:41:01 -0700
Hi All,
Here is a 2-cent tip that is a little Perl script for looping through directories.
#!/usr/bin/perl # Thomas Bonham # Create on 05/27/2008 # Function is for list all contents of a directory use Cwd; sub searchdir { my $dir = shift; my $cwd = getcwd(); if ($dir ne "") { unless (chdir($dir)) { print STDERR "Unable to chdir to $cwd/$dir: $!\n"; return; } } opendir(DIR, "."); my @files = readdir(DIR); closedir(DIR); foreach my $file (@files) { next if $file eq "." || $file eq ".."; if (-d $file) { searchdir($file); next; } # Do what you would like here print getcwd(),"/",$file,"\n"; } chdir($cwd); } sub main() { searchdir(); } main();
Thomas
[ Thread continues here (2 messages/1.68kB) ]
2-cent Tip: Compiz-Fusion
Jonathan Clark [clarjon1 at gmail.com]
Fri, 25 Apr 2008 06:13:25 -0400
This tip goes out to all the students who use Linux, with Compiz-Fusion...
How many students have been working on something, like, for example, updating their software, or checking their e-mail, or getting tech support on IRC, when a teacher walks up, glances at your screen, and gasps because "That's not school work! You, you must be Hacking the system!!"
*raises hand*
Thanks to Compiz-fusion, I've been able to avoid this with even the most... shall we say obstinate? teachers out there...
As some of you may know, Compiz-Fusion allows one to reduce the opacity of individual windows by using <Alt>+<ScrollWheelDown>, and restore the opacity with <Alt>+<ScrollWheelUp>.
However, some may not be fooled... Not to worry, you can make it look like it's a part of your desktop background...
Open up the CompizConfig util, and activate the Freewins plugin. Press <Ctrl>+<Shift>, click in the window you want to make more hidden, and move the mouse around. Your window has... rotated! Press <Ctrl>+<shift>+<MouseButton3> or <MouseButtons1and2simultaneiously> to return the window to its proper rotation. The only drawback currently with this rotated window is that the inputs, like text input boxes, menus, buttons, even the window decorations, still expect the mouse clicks to be where the items are supposed to be when the window is non-rotated.
Hope this makes for some more happy Linuxing!
Of course, the best way to keep from getting into trouble, is to do your work in class. And not goof off. But, if you're using Linux, and it looks different from what some teachers expect, no amount of explaining will keep you out of their "watchlists". Been there, done that. Even had to explain to the principal (!!) that I wasn't doing anything wrong. That was not a Good Day...
-- Clarjon1 Proud Linux User. PCLinuxOS on Dell Inspiron 1501, 1 Gig RAM, 80 Gig hard drive 1.7GHz AMD Athlon 64bit dualcore processor Contact: Gmail/gtalk: clarjon1 irc: #pclinuxos,#pclinuxos-support,##linux on freenode QOTD:
2-cent Tip: make script command logs without escape character
Mulyadi Santosa [mulyadi.santosa at gmail.com]
Tue, 27 May 2008 13:34:22 +0700
Tired of script-generated logs cluttered with escape characters all over the place
Try to change the terminal into "dumb" and repeat:
$ export TERM=dumb $ script <do whatever necessary to be logged> <type exit or press Ctrl-D> $ export TERM=xterm Switch back to vt100, xterm, or other when you're done, to recover your terminal's original mode.Observe the generated log:
$ cat -A typescript mulyadi@mushu:/tmp$ ls^M$ gconfd-mulyadi^I^I mc-mulyadi^I ssh-tYecBM5768^M$ gedit.mulyadi.3088662139 orbit-mulyadi Tracker-mulyadi.5855^M$ keyring-HzVeHi^I^I plugtmp^I typescript^M$ mapping-mulyadi^I^I sqlGIskW0^I virtual-mulyadi.SGmoJb^M$
Note that we see ^I, ^M, and so on because of the -A option on "cat". This is needed, so we are sure there are no escape characters there.
[ Thread continues here (11 messages/13.12kB) ]
2-cent Tip: Poisoning the spammers
Ben Okopnik [ben at linuxgazette.net]
Sat, 10 May 2008 13:03:36 -0400
I saw a Web page the other day, talking about a cute idea: since the spammers are always trawling the Net for links and e-mail addresses, why not give them some nice ones? For a certain value of "nice", that is...
However, when I looked at the implementation of this idea, the author had put a "badgeware" restriction on using it - not something I could see doing - so I wrote a version of it from scratch, with a few refinements. Take a look:
http://okopnik.com/cgi-bin/poison.cgi
A randomly-generated page, with lots of links and addresses - with the links all pointing back to the script itself (somewhat obscured, so they don't look exactly the same), so the spammers can harvest even more of these addresses. Mmm, yummy!
The addresses are made up of a random string "at" a domain made up of several random words joined together with a random TLD. There is some tiny chance of it matching a real address, but the probability is pretty low.
If you want to download this gadget, it's available at http://okopnik.com/misc/poison.cgi.txt (and, once the next issue of LG comes out, at 'http://linuxgazette.net/151/misc/lg/poison.cgi.txt'.) I suggest renaming it to something else , and linking to it - the link doesn't have to be visible [1] - from a few of your real Web pages. If enough people started doing this, life would become a lot more pleasant. Well, not for spammers, but that's the whole point...
[1] '<a href="poison.cgi" border="0"> </a>' at the end of a page should be invisible but still serve the purpose.
-- * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
[ Thread continues here (3 messages/4.57kB) ]