joeware - never stop exploring... :)

Information about joeware mixed with wild and crazy opinions...

4/4/2008

Old but good…

by @ 4:45 pm. Filed under humour

Excerpts from a Dog’s Diary
============ ========= ======
8:00 am – Dog food! My favourite thing!
9:30 am – A car ride! My favourite thing!
9:40 am – A walk in the park! My favourite thing!
10:30 am – Got rubbed and petted! My favourite thing!
12:00 pm – Lunch! My favourite thing!
1:00 pm – Played in the yard! My favourite thing!
3:00 pm – Wagged my tail! My favourite thing!
5:00 pm – Milk bones! My favourite thing!
7:00 pm – Got to play ball! My favourite thing!
8:00 pm – Wow! Watched TV with the people! My favourite thing!
11:00 pm – Sleeping on the bed! My favourite thing!

 

Excerpts from a Cat’s Diary
============ ========= ======
Day 983 of my captivity.
My captors continue to taunt me with bizarre little dangling objects.
They dine lavishly on fresh meat, while the other inmates and I are fed hash or some sort of dry nuggets. Although I make my contempt for the rations perfectly clear, I nevertheless must eat something in order to keep up my strength.

The only thing that keeps me going is my dream of escape. In an attempt to disgust them, I once again vomit on the carpet.

Today I decapitated a mouse and dropped its headless body at their feet.
I had hoped this would strike fear into their hearts, since it clearly demonstrates what I am capable of. However, they merely made condescending comments about what a “good little hunter” I am.

Bastards!
There was some sort of assembly of their accomplices tonight. I was placed in solitary confinement for the duration of the event.

However, I could hear the noises and smell the food. I overheard that my confinement was due to the power of “allergies.” I must learn what this means, and how to use it to my advantage.

Today I was almost successful in an attempt to assassinate one of my tormentors by weaving around his feet as he was walking. I must try this again tomorrow — but at the top of the stairs.

I am convinced that the other prisoners here are flunkies and snitches.
The dog receives special privileges. He is regularly released – and seems to be more than willing to return. He is obviously retarded.

The bird has got to be an informant. I observe him communicate with the guards regularly. I am certain that he reports my every move. My captors have arranged protective custody for him in an elevated cell, so he is safe.

For now…

Rating 3.00 out of 5

Things are not always what they appear… Faked Rape on YouTube…

by @ 4:44 pm. Filed under general

http://www.thesun.co.uk/sol/homepage/news/article831344.ece

but then

http://www.theregister.co.uk/2008/04/01/alleged_youtube_rape_victim_arrested/

Rating 3.00 out of 5

4/2/2008

:)

by @ 7:58 pm. Filed under humour

How many years later and this STILL cracks me up the instant I see it…

BTW, my sister looks like Cameron Diaz… See her artwork here (Shank’s that is, not Cameron’s).

 

Rating 3.00 out of 5

Parsing quoted CSV files with perl

by @ 6:38 pm. Filed under tech

This post brought to you by Colbie Caillat’s song Realize, Microsoft Windows Server 2008 Server Core,  and the letter Q.

 

I always end up rewriting code to parse CSV files in perl for some reason or another so I thought I would write it again and then post it here so when I don’t find it in my code snippet library the next time I can find it here… And also so you can use it too of course…

Background… perl has great text handling capability, but the method used to split up a line into tokens or in the case of CSV files into fields called the “split” function doesn’t take quotes into account which is a bit of a pain. This isn’t unusual, most default tokenizing functions do the same thing.

Perl does have an easy answer though… One of the modules that comes with the ActiveState dist[ribution] by default is called Text and it includes a routine for parsing lines with quotes that can be used…

The script supplied below will take a CSV file, read the header and then output the lines broken up in a readable format like so

Sample CSV

“dn”,”name”,”objectclass”,”description”,”gplink”
“OU=Domain Controllers,DC=test,DC=loc”,”Domain Controllers”,”top;organizationalUnit”,”Default container for domain controllers”,”[LDAP://CN={6AC1786C-016F-11D2-945F-00C04fB984F9},CN=Policies,CN=System,DC=test,DC=loc;0]”
“OU=Users,OU=My,DC=test,DC=loc”,”Users”,”top;organizationalUnit”,””,” “
“OU=My,DC=test,DC=loc”,”My”,”top;organizationalUnit”,””,””
“OU=Groups,OU=My,DC=test,DC=loc”,”Groups”,”top;organizationalUnit”,””,””

Sample output

G:\\Dev\\perl\\ParseCSV>outputcsv.pl oudmp.csv
description: "Default container for domain controllers"
dn: "OU=Domain Controllers,DC=test,DC=loc"
gplink: "[LDAP://CN={6AC1786C-016F-11D2-945F-00C04fB984F9},CN=Policies,CN=System,DC=test,DC=loc;0]"
name: "Domain Controllers"
objectclass: "top;organizationalUnit"

description: ""
dn: "OU=Users,OU=My,DC=test,DC=loc"
gplink: " "
name: "Users"
objectclass: "top;organizationalUnit"

description: ""
dn: "OU=My,DC=test,DC=loc"
gplink: ""
name: "My"
objectclass: "top;organizationalUnit"

description: ""
dn: "OU=Groups,OU=My,DC=test,DC=loc"
gplink: ""
name: "Groups"
objectclass: "top;organizationalUnit"

That makes it a bit easier to see what you have in front of you. 

Here is the script: 

use Text::ParseWords;

#
# Open CSV file
#
my $csvfilename=shift;
open fh,"<$csvfilename" or die("Couldn't open CSV file $csvfilename:$!\\n");


#
# Break up the header and map lowercase normalized header labels to field numbers
#
my $header=<fh>;
@headerfields=ParseCSVLine(lc($header));
my $cnt=0;
my %maphash=();
map {s/\\"//g;$maphash{lc($_)}=$cnt++} @headerfields;


# 
# Read file and output
#
while ($line=<fh>)
 {
  my @vals = ParseCSVLine($line);

  foreach $thisfield (sort keys %maphash) 
   {
    print "$thisfield: $vals[$maphash{$thisfield}]\\n";
   }
  print "\\n";
 }


sub ParseCSVLine
 {
  my $line=shift;
  my $delimiter=shift or ",";
  chomp $line;
  return &parse_line($delimiter, 1, $line);
 }

 

Within the script you can also do things like

print “The GPLinks for this entry are: $fields[$maphash{gplink}]\n”;

And regardless of where in the CSV file the gplink column is (i.e. you have different format CSV files) you will output the column that has the gplink info…

Looks like object type handling but within a completely text based passing mechanism so the info could have come through email or ftp or web page or wherever…

Could it be shorter? Of course, but the point here wasn’t making the smallest code. Just show something off and have it for later re-use.

 

   joe

Rating 3.00 out of 5

Good blog article on enabling debugging logging

by @ 5:58 pm. Filed under tech

http://blogs.technet.com/askds/archive/2008/04/02/directory-services-debug-logging-primer.aspx

Rating 3.00 out of 5

Sarah Silverman and Jimmy Kimmel – Risque….

by @ 1:36 am. Filed under humour

ABSOLUTELY HILARIOUS…

 

…but very Risque…. Watch the language…

 

Sarah’s message…

http://www.youtube.com/watch?v=wnVJZkDuVBM

 

And Jimmy’s response…

http://www.youtube.com/watch?v=sIQrBouWRiE

Rating 3.00 out of 5

Cat owners will understand…

by @ 1:36 am. Filed under humour

Rating 3.00 out of 5

4/1/2008

Stupid LOL rafalot Blog

by @ 7:01 am. Filed under general

As far as I can tell, this blog http://www.rafalot.com/ scans other blog headlines for LOL and then posts them to that blog so you hit them in searches and give them ad dollars… WTF. I hate morons like this.

Rating 3.00 out of 5

Teamwork

by @ 7:00 am. Filed under general

Rating 3.00 out of 5

This picture just makes me laugh and laugh and laugh.

by @ 2:47 am. Filed under humour

He is quite the tough guy…. Don’t mess with the pig. 🙂

 

Rating 3.00 out of 5

[joeware – never stop exploring… :) is proudly powered by WordPress.]