BibleGateway.com Verse Of The Day

Friday, March 14, 2008

Trashy Yet Effective Oracle Trick

I need to post this so I can remember it next time I screw up...


I was running an Oracle import (imp) on my local Oracle 10g XE instance today, and realized I did it incorrectly and imported everything into the SYSTEM schema. Oh crap, I can't just wipe everything out, it's my SYSTEM schema! I need surgical precision to only remove the crap and leave all the Oracle stuff unscathed.

I could go through and drop each table I created, but there were hundreds.

Then, like a tornado in a trailerpark, it hit me. An idea that walks the fine line between genius and insanity. All the new table names started with a common prefix, which for sake of discussion I will call "BLAH_". So in Squirrel I run the following query:

select 'drop table system.' || table_name || ';' from all_tables where owner = 'SYSTEM' and table_name like 'BLAH_%'

Then cut and paste the results back into the Squirrel query runner and run the results as a script.

I'm sure there's an "official" way to accomplish the same thing, but screw that, this was extremely quick and kind of fun.

Trashy yet effective.

Tuesday, March 11, 2008

Whores, Spitzer, Swallows

I don't usually dive into politics on here, but everyone loves a good high profile prostitution sting....


With Gov. Spitzer, a.k.a. Client #9, getting busted using the services of a high class prostitution ring, some serious questions need to be answered. I'm not talking about the normal political crap like will he be impeached?, will he resign?, will he be arrested?, will other high-profile clients be outed?, etc. I'm mean questions like, what is the difference between a high priced hooker and a regular street hooker, anyways?

Really, they both take money from strangers and then slide down the dudes' meat-poles. They collect more DNA samples in a day than the CSI folks collect all year. That's a nasty, filthy whore, whether it costs $50 or $5000.

So what does the extra cash buy?

  • Is there such a thing as a higher class of venereal disease?
  • Does draining your man-goo feel better when you also drain your bank account?
  • Is it somehow less disgusting to think a thousand rich dudes impaled the whore with their man-swords, as opposed to a thousand regular dudes?
  • Do they share a glass of champagne with you after the deed, instead of hitting the crack pipe and watching Jerry Springer?
  • Do you get a souvenir hat or t-shirt or something? Like when you ride a roller coaster and they snap your picture coming down the big drop off?
Hindsight being 20/20 and all, I'm guessing the soon-to-be-former-governor of New York is probably thinking a 6 pack of Corona, a bottle of hand lotion, and some adult pay-per-view might have been the safer choice for a night out on the town.

Thursday, February 28, 2008

Anticipation is Worse Than Real Thing

Well, they say the anticipation and waiting is harder than the actual event, for example waiting for a dental procedure or something like that. They're right -- 2 of my recent stresses have been relieved in the past two days, and all the fretting has been for nothing.

My truck passed NYS inspection without even needing so much as a windshield wiper blade. I was worried about the rear brakes, since the front ones were in such bad shape when I did them last month (needed new pads, new rotors, and on one side I ended up replacing the whole caliper and shearing off a banjo bolt, but that's another story). Getting the brakes replaced would have cost a butt load of cash we just don't have right now.

Then yesterday we finally got our act together and did our taxes. The big nagging fear, no matter how much math you do throughout the year, is that all of a sudden we owe the government butt loads of cash we don't have. Nope, we're still getting a return -- nothing too elaborate, but at least we're not paying.

Goes to prove another saying right -- "Procrastination is a lot like masturbation. It feels good while you're doing it, but in the end you just screw yourself".

Monday, February 25, 2008

FCKeditor - Embedded HTML Editor

For a recent project, I wanted something fancier than a regular HTML text area to allow user input with formatting. "Something like the editor on Blogger", I thought.

After hitting Google, I ran across FCKeditor. I had heard of it before, and even played with the demo once, but never did anything with it. Never had much of a reason to. Today that all changed.

After reading through the Developers Guide, I downloaded the ZIP, unpacked into my public web directory, and had it working in no time. In less than 30 minutes, I had the FCKeditor completely tied into an existing Rails form, replacing a boring old text area. After a few minutes of testing inserts and updates, and some cross-browser testing with Firefox and Internet Exploiter, I was happy.

There were only a few lines of JavaScript code to add to the page, and those are all spelled out in the Developer's Guide, so I don't feel the need to repeat those here.

Overall, I was pleasantly surprised. Unlike a lot of open source projects out there, this was extremely easy to get started with, easy to install and embed into existing applications, and the documentation was pretty good for a change. The quality so far has also been nothing short of impressive. (the editor is more full-featured than the one Blogger uses.)

It's licensed under the GPL, LGPL, or MPL (your choice), and can be embedded in any project, open source or commercial. Also, in addition to the JavaScript version I used today, there are versions for JSP, ColdFusion, PHP, Python, etc.

This project today was just a personal side project, but I think FCKeditor might find it's way into my arsenal for work projects as well.

Thursday, February 07, 2008

Reading And Writing Text Files in Ruby

On a recent project, I had everything automated up to the point where I had to give feedback to the business analysts on what, if any, of their data had to be fixed and re-run.

I ended up writing some Ruby scripts to run through a file of transaction responses, and sort out the various error types into separate files, and produce a summary report of the error counts in each category.
Now the only manual part was cutting and pasting the summary into an email, and attaching the various sorted files.

I was pleasantly surprised at how easy it was to read and write text files in Ruby. Let's say you just want to read a text file, line by line, and spit it back out, a la "cat"...
File.new(filename, "r").each { |line| puts line }
Wow, that was easy, eh? Let's try reading that file into an array for use later...
results = []
File.new(filename, "r").each { |line| results << line }
Let's say you want to capitalize everything in the file, and spit it out to a new file...
out_file = File.new("upper_case.txt","w")
results.each do |line|
out_file.puts line.upcase
end

That was easy. It's probably obvious, but the first argument passed to the File constructor is the filename, and second is the read/write flag.

For comparison' sake, let's read a file in Java and spit it out line for line...
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
...
BufferedReader is = new BufferedReader(new FileReader(fileName));
String line = "";

try {
while (line != null)
{
line = is.readLine();
System.out.println(line);
}
catch (Exception e) { /* do nothing for now */ }
finally
{
try {is.close();}catch(Exception f) { }
}

Definitely not "hard", but it is a bit more code. Writing a file is very similar, except of course you use FileWriter and BufferedWriter instead of FileReader and BufferedReader, and write to the file instead of reading from it.

I'm not really trying to prove anything here -- Ruby isn't better than Java, Java isn't too hard or too verbose, etc. I like Java. I like Ruby. Against my better judgment, I even like Oracle, but that's another topic. I just found that working with files was easier than I expected, even for a Ruby beginner like myself.

Tuesday, February 05, 2008

Funny Thing About Taxes

The other day Woot.com's product description included a funny little rant about taxes....

"The worst thing about taxes is that you’re supposed to compute the total yourself. What if you ate at a restaurant and when you said hey, what do I owe you? They said you figure it out. And you thought about what you’d eaten and said well, I guess that’d be about $7.25, and they said no, it’s $11.40. Plus now we’re going to charge you an extra three bucks for trying to cheat us. If they knew what you owed them, what was the point of making you figure it out? Just to be jerks, probably. Or maybe in hopes you’d miss high, which is basically how taxes work."

Thursday, January 31, 2008

Lucid Vending Dreams

They better have Twinkies, Ho-Ho's, and Doritos in this machine as well, or there might be a riot when the munchies kick in....
http://videos.howstuffworks.com/reuters/3905-marijuana-vending-machines-video.htm

Tuesday, January 29, 2008

More Childish Artwork


My wife got a sweet scanner/copier/fax/printer/toaster for Christmas, so I got to scan a piece of "art" I did with my kids. I guess it's a redneck programmer, complete with bad teeth.

And the other one is a duck....

Thursday, November 29, 2007

Opening JAR/WAR/EAR With Windows XP 'Compressed Folders'

Why do I keep doing Google searches to find this site, when I can just post a link here? I'm an idiot.

More importantly, why do I really keep needing to look this up? I'm an idiot.

Wednesday, November 28, 2007

Splunkin' Like A Madman And Log Management

Splunkin'

After playing with Splunk over a year ago (and liking what I saw) , we finally got the green light to go forward with an implementation at work. Splunk is a log aggregation and search tool. Basically it's a really fancy way of grep'ing through log files without logging in to each server and grep'ing through logs. One search will search logs across all the servers.

Right now I am in the process of estimating our peak daily volume, which more of less means I am ssh'ing in to each app server and Apache server and looking at the file sizes for the various logfiles. The licensing for Splunk is tiered based on peak daily volume, with a free version that will index up to 500MB a day. Their pricing model seems like a real bargain when you compare it to other enterprise software vendors out there, especially when you see the license fee is a "perpetual license" -- you pay once and it is good forever. If your logging volume increases, you can upgrade the license without screwing around with the software installation, and the cost is prorated as the difference between the old and new.

Everyone I have dealt with over at Splunk has been really cool to work with so far as well. Not a bunch of pushy sales-droid types, and they seem more than willing to work with you for unique configurations.

This should make it a lot easier to find and pinpoint issues across our 3 Jboss clusters and the handful of stand-alone Jboss and Tomcat servers and multiple Apache servers.

Apache Log File Management

And speaking of logs, we had an issue where the mod_jk.log file hit the 2 gig limit (32 bit Linux) on one of our Apache servers the other day. That was fun to track down, since some stuff seemed to work and other stuff did not. Our web applications were working fine, but web services calls into our boxes were failing. According to our Jboss logs, we were processing the WS calls and returning valid responses, but the clients were getting errors about the connection being closed while reading the response, or null objects being returned, depending on which platform they were connecting from.

So now I am working on getting logrotate setup for our Apache installations. While I am in this mode, I think I'll whip up some Nagios checks to alert if the filesizes grow to say 1.5G (which shouldn't happen with daily log rotation and compression).

Setting it up is pretty easy. I edited the /etc/logrotate/httpd file to add the following:

/app/j2http/apache-2.0.55/logs/*log {
daily
rotate 10
copytruncate
notifempty
compress
}

Tuesday, November 27, 2007

Chicken Farming Comes To An End

Our first experiment in raising chickens for food ended this past weekend. We had 5 Rhode Island Red hens left, and I really didn't want to take care of them through our harsh upstate winter. Since I was already spending my weekend butchering and packing my deer, making venison jerky, and grinding venison into burger, I figured I would go ahead and take care of the last 5. So now, with 5 chickens in the freezer and none in the coop, our first year as chicken farmers has officially ended.

We learned a lot and had some fun raising chickens, and the neighbors didn't seem to mind too much. The meat and extra eggs were nice as well. This is definitely something we will do again in the spring, but there are a few things I will do differently.

  • Make the chicken run around the coop bigger. It was originally supposed to be bigger but I ran out of time and ran into big rocks on the one corner. So I let them free range a lot, which wasn't terrible, but led to some minor annoyances here and there.
  • Make a nest box. I meant to do this but again ran out of time. Then I read about chickens not laying until they are 6-8 months old, so figured they would all be gone by then anyways. Then my neighbor Dave started finding eggs in his flower garden, and we started finding eggs in our barn. If we start them with a nest box and minimize the free ranging, we should have to go on Easter egg hunts all the time.
  • Make the chicken run higher or put a top on it. Even when I closed the chickens in, they literally flew the coop and got out anyways.
  • Get some bigger meat chickens. The Buff Orpington's and Rhode Island Reds we got are known as dual purpose birds, good eating size plus good layers. It seemed to take forever for these birds to reach a good eating size, so next time I will get some Cornish X Rocks or other big meaty type birds as well as the Buff's and Red's.
  • Get an open watering trough. The watering jug I got is a pain, since you have to take it apart and turn it over to fill, then put it together and turn it back over. It would be so much easier (and drier) to just pour water into a trough instead of messing with that thing.

Monday, October 01, 2007

Let's Rock

All right, my wife's at work, my kids are in bed, Lexi is sleeping. I've got Dead Poetic on my iPod, XAMPP on my thumb drive, and a brilliant new MySQL database schema created for my new bastard stepson of a side project. Time to generate some scaffolding! For this top secret project, I will write the back-end admin stuff using Ruby on Rails. For the front end, I haven't quite decided yet. I'm just not sure how RoR scales up for an external facing website, and for what I am doing it might be easier to use Java anyways, as I can write a few JSP tags to use on any of the pages, and use Velocity as the templating engine to build the special configuration page.

Then again, I just got paged for a work issue, and that trumps side projects. DAMMIT!

Any Given Sunday

The Bills pulled out their first win of the season against the Jets, which was the first clue that something was "wrong".

Over half of my Last Man Standing pool (myself included) picked San Diego since they were so highly favored to win, and THEY LOST!

On top of that, my 3-0 Steelers went 3-1, against the freaking CARDINALS!

Must be a bad dream, must be a bad dream, must be a bad dream!

Don't Bother Me

The national "do not call" registry expires every 5 years, so first wave is about up. To re-register.... https://www.donotcall.gov/Register/Reg.aspx

Thursday, September 27, 2007

Rhythm's Gonna Get You

Last night was Raina's big 4th birthday, so we went to Chuck E. Cheese. On the way home, our Sirius radio was, of course, tuned to "Kid's Stuff", and annoying little Dora The Explorer was singing some cheesy 80's song, Rhythm's Gonna Get You. The song was bad enough the first time around, did we really need Dora to "sing" it for us?

Anyway, that's not even the point. Half way through the song, Raina asked us if Rhythm is a bad guy? Took us a few seconds to realize what she was getting at. In the Disney movies they've seen, the bad guys "get you", so Rhythm must be a bad guy since it is trying to "get you". It was funny, and also kind of scary. As adults, we see or hear things but don't notice anything odd, but the kids are processing it and picking it apart, not missing a single thing.

Word, Character, Line Counter Ruby Script

I've been on a few projects lately that involve loading data files that I get from other teams. When I get a file, it's nice to see how big it is to get an idea of how long it will take. Opening the file in a text editor and going to end of file to see the row number can be a pain, especially for big files. Also, I'm on a Windows desktop, so tools like "wc" aren't built-in, and launching Cygwin and getting to the right directory can be a pain in itself (cd /cygdrive/c/Documents\ and\ Settings/ran488/Desktop), so I whipped up this quick Ruby script to give me all the file info I want.

Here's the Ruby script (fileinfo.rb) to get the count of lines, characters, and words in a text file. It also spits out the min and max line size as well. The source can be downloaded at http://www.frontiernet.net/~nicholson150/fileinfo.rb.


#!/usr/bin/env ruby

if __FILE__ == $0
if ARGV.length < 1 then
puts "Usage: #{$0} filename"
exit
end

results = []
words = 0
chars = 0
minline = 0
maxline = 0

filename = ARGV.first
File.new(filename, "r").each { |line| results << line }

puts "#{filename} has..."
puts " -> #{results.size} lines."


results.each do |line|
chars += line.length
words += line.split.length

if line.length > maxline then
maxline = line.length
elsif line.length < minline then
minline = line.length
end

end
puts " -> #{words} words."
puts " -> #{chars} characters."
puts " -> #{minline} character shortest line length."
puts " -> #{maxline} characters longest line length."

end


Here's an example of the output....





C:\cvs\MqThrottler>fileinfo.rb PA_CSS_Test_Load_0911.txt
PA_CSS_Test_Load_0911.txt has...
-> 10008 lines.
-> 58021 words.
-> 4356721 characters.
-> 0 character shortest line length.
-> 489 characters longest line length.

Monday, September 17, 2007

Lexi


Here's an updated picture of Lexi the Wheaten Terrier. She is about 7 months old here, mostly white and wheat color with just hte black face remaining.

Thursday, September 06, 2007

PDFCreator

Apps like OpenOffice.org have built-in PDF export functions, and Mac OS X has a built in PDF export in the print dialog.

But if you're running apps on Windows that don't have this feature, you can download and install PDF Creator. It installs itself as a "printer" on your PC. When you choose to print from any application, choose this printer instead of your normal printer.

Bulk File Renamer in Ruby - file_rename.rb

My updated bulk file renamer script is listed here. (http://www.frontiernet.net/~nicholson150/file_rename.html) along with the Ruby source code.

I first started messing with this concept in this post, but have refined it a bit since.

Along with the Ruby compiler I mentioned yesterday, this could be compiled and dropped in your PATH somewhere (e.g. Windows dir), and then you could run it anywhere as if it were a native Windows/DOS command. I may end up doing that on my home PC to help rename the imported digital photos-- "DCP_05483.JPG" just isn't as descriptive as "Jeep Camping Trip 2007 - 012.jpg"

Tuesday, September 04, 2007

RubyScript2Exe - The Ruby Compiler

I've been playing with RubyScript2Exe (http://www.erikveenstra.nl/rubyscript2exe/index.html) lately, and it's pretty sweet. It's a Ruby "compiler" to generate executables from your Ruby scripts. Since it embeds the Ruby runtime and any libraries in the executable, even simple scripts can "bloat" up to bigger sizes than you might expect, but if distribution is your thing, so what?

Maybe you want to share some of your cool scripts and development tools you've created, but can't count on your intended audience having Ruby installed (what's wrong with them, anyways?), or maybe it would take too long to explain what Ruby is and how to run the scripts. Or maybe you just don't want people screwing with your perfect source code. Or perhaps, you are ashamed of your trashy, hack-n-whack coding?

Whatever the reason, this thing is the nuts. Just download a single rubyscript2exe.rb script and run it against your app. I've only tried it on single files on Windows so far, but it is supposed to create Linux executables as well, and will allegedly work on more complex, multi-*.rb-file apps.