Just_Another_Perl_Hacker.pm

Jan 08
2008
package Just_Another_Perl_Hacker; $$
perl -MJust_Another_Perl_Hacker -e 's|(?< =\w)_| |g && tr/:://d && print for keys %main::'

“Argument list too long”

Jan 08
2008

Given that linuxjournal has some good points, there is no need for another solution, except in the cases when you operate on different machine. Here is oneliner solution:

irb console #remove Opera cached files

too_many_files = "~/.opera/cache4/"
 
Dir.new(too_many_files_dir).each do |f|
  File.file?(f) && File.unlink(f)
end

Getting ip addresses from log file

Jan 08
2008
perl -ne '$_{$1}=1 if /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;eof&&{print join("\n", sort keys %_)}' access.log

Fast ICMP scanner (Perl oneliner)

Jan 08
2008

[localhost]$

time perl -MNet::Ping -e '$p = Net::Ping->new();
@hosts = qw(
127.0.0.1
172.16.0.1
172.16.0.2
172.16.0.5
172.16.0.254);
#the significant detail
$p->{"timeout"} = 0.005;
for (@hosts) { print "$_ is ".($p->ping($_) ? "up" : "down").$/ }'

127.0.0.1 is up
172.16.0.1 is up
172.16.0.2 is down
172.16.0.5 is up
172.16.0.254 is down

real 0m0.062s
user 0m0.040s
sys 0m0.000s

Simple file hiding

Jan 08
2008

irb console

$/ = "\r\n"
 
# addition of .mp3 file to .gif file
File.open('test.gif', 'a') do |fh|
  fh < < "\r\n#{File.readlines('test.mp3')}"
end
 
# extraction of the .mp3 content
File.open('extracted.mp3', 'w') do |fh|
  fh << File.readlines('test.gif')[1..-1]
end

Calendar

January 2008
M T W T F S S
« Dec   Feb »
 123456
78910111213
14151617181920
21222324252627
28293031  

Tags