Entries Tagged as 'tip'

Saturday, January 16th, 2010

Oracle Delete Taking a Long Time

It may look like your delete statement is hung, but ff your table has foreign keys in another table without indexes on that column Oracle will full table scan that other table for every row that you’re deleting. Hopefully this saves someone some time. Bookmark to:

Tuesday, October 6th, 2009

Luhn Digit Generation Oracle PL/SQL Implementation

Here's how to generate a Luhn Mod-10 Check Digit. It's implemented as a function in oracle PL/SQL. I spent 2 hours looking for this online, then decided to implement it myself since it's not that hard. Anyway, I thought I'd post it here for the next person trolling google for it. This is useful for [...]

Wednesday, May 13th, 2009

Capturing Uncaught Java Exceptions in a Bash Shell Script

I was burned one to many times by chaining dependent java programs together in a bash script. By default the java executable will return zero if the program exited manually, and 1 if there was an uncaught RuntimeException. Let's say test.sh runs a java program, we want to run it 3 times, but if it [...]

Thursday, February 19th, 2009

Mylyn + Trac + wsgi

I am using mod_wsgi instead of mod_python for my trac .11 install. I'm also using the AccountManager plugin for authentication, and don't have anonymous access setup. Anyway, authentication wasn't working (through XML RPC) hence mylyn didn't have the perms to do anything, and was silently defaulting to anon mode. even though I had the XML [...]

Wednesday, January 21st, 2009

Easily Creating Fixed Length Flat Files With Groovy

Here's an (I think elegant) way to create flat files with Groovy. I want this script to be easy to read by future developers. So if someone wants to know what the format of the file is they can see it just by opening the script. Classes We'll Use Groovy: SQL: We'll use this library [...]

Friday, February 15th, 2008

Limiting log4j SMTPAppender

I wanted to set a maximum amount of e-mails that SMTPAppender would send after filling up a mailbox with 30,000 damn e-mails. Turns out it was pretty damn easy, I set up my appender in a java class, and the SMTP appender has a method called setEvaluator that takes an instance of TriggeringEventEvaluator, so I [...]

Monday, September 17th, 2007

Killing a process by name in ubuntu

I have to kill mongrel alot because it's a flea-bitten mutt. My usual method was to do a ps -aux | grep mongrel , find the pid and kill it! Annoying and stupid! Now I just use the nice pkill tool in ubuntu like so. pkill mongrel boom! All bad doggies killed! This probably works [...]

Friday, September 14th, 2007

Capturing STDERR with ruby backticks

I was writing a ruby script today that ran a linux command for every line in a file. The problem was the backtick operator in ruby only captures stdout, here's a little trick to get stderr as well. (*nix only) out = `ourlinuxcmd 2>&1` the 2>&1 bit tells the shell to redirect stderr to stdout [...]

Monday, September 10th, 2007

Running rails with mongrel for a specific sub directory

I've started using mongrel for running rails apps with apache2 and mod_proxy , it works like a charm and allows you to run multiple rails apps and mongrel instances on one server. Your proxy setup looks like this in your httpd.conf or vhost.conf <VirtualHost *:80>     ServerName myapp.com     ServerAlias www.myapp.com     [...]

Saturday, September 1st, 2007

♥ HTML Heart Code ♥

Here's how you make a heart in HTML, &hearts; Now, stop coming here for that! I'm sick of seeing you in my referral logs! *Edit - Now i'm #1 in google for this unwillingly! Oh, well go ahead and try it out in the comments you weirdos. Bookmark to:

Sunday, July 22nd, 2007

Java App Empty Window under Compz-Fusion / Beryl

This weekend I was playing around with Ubuntu 7.04 and Compiz-Fusion, I didn't have any major problems until I tried to get Oracle SQL Developer and Aqua Data Studio to work, they would start up but no interface would be drawn. Well the problem is that they were trying to figure out the Window Manager [...]

Wednesday, July 4th, 2007

$ORACLE_HOME permissions

For some reason in the latest 10g oracle download for linux they fubared the perms for the $ORACLE_HOME directory, not allowing non-oracle users to run any oracle client tools like sqlplus. Causing awesome errors like: sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory Also this completely [...]

Friday, June 29th, 2007

One Time Case Insensitive Vim Search

Everyone knows you can type :set ic to ignore case in vim, however sometimes you want to do a case insensitive search on a 'case by case' basis, no pun intended. to do that you'd type /\csearchstring That way you don't have to go insenstive for your whole session. Bookmark to:

Wednesday, June 20th, 2007

Randomizing Query Results in Oracle

I was doing some work this afternoon, and I needed some sample id's from a database query, however all the data ended up being related to the same person because of the ordering of the results. There must be a better way, i want random results in my resultset. Here's how (in oracle), order by [...]

Monday, May 21st, 2007

Focusing first form element on page load with prototype

All in one line thanks to prototype Event.observe(window, 'load', function(){Form.focusFirstElement('yourFormId');}, false); Bookmark to:

Friday, March 16th, 2007

Accessing main query aliases from subquery

I am stupid, I never fully understood Oracle Subqueries. Let me give you an example, I had a really big view where I wanted to access stats of child tables based on a parent table. For example, let's call that table checks, I wanted to know how many responses were linked to each check. We [...]

Tuesday, October 24th, 2006

Perl One Liner – Search Replace String in File

This is one of the most useful perl one-liners. Search and Replace a string in a text file. perl -0777 -i -pe 's/patterntomatch/replacewith/g' inputfile Let's break this down -0777: treat file as a single line, this way we don't have to worry about ranges on our regex. -i: operate on file in place. super dangerous [...]

Monday, October 9th, 2006

Formatting Numbers in Oracle and Postgres

When dealing with large numbers in oracle sometimes it can be hard to read the results from a query with no formatting in the results. I know I have misread numbers from a query many times. Well, I finally got around to looking up how to format numbers in oracle. And who knew -- TO_CHAR [...]

Friday, October 6th, 2006

Defeating Firewalls with Putty and SSH

Once in a while we all get stuck behind a firewall and just have to get around it. You could use one of the many anonymizer web browsing sites which is most likely blocked or use some random proxy in Eastern Europe that features a totally leet 476 ms ping. Or if you have an [...]

Friday, October 6th, 2006

Creating comma delimited lists with vim

Sometimes you just want a comma delimited list. But all life has handed you is a newline delimited list. Lucky for us, God made vim. Bookmark to: