Category Archives: tips

Remove existing jar signature and replacing it with a new signature.

After signing a jar file with an existing signature, you may get an error like this:

jarsigner: java.lang.SecurityException: invalid SHA1 signature file digest

This is because you should first remove the old signature. To do this, they say to unzip the jar file and remove the META-INF directory and zip it back. Fortunately the zip command has an option for this.

zip -d "META-INF/*" yourFile.jar

Then use jarsigner to sign the file, this varies depending on your keystore format. Here’s an example:

jarsigner -keystore yourKeyStore.pfx -storetype PKCS12 yourFile.jar myAliasInKeystore

Free simple screen sharing

Need an easy way to share your screen with someone, but don’t want to pay an arm and a leg and are too lazy to setup a VNC session over an ssh tunnel?  Check out screenleap, it’s simple and you get 2 hours a day of screen sharing for free.  You don’t even have to sign up for an account to try it.

It appears to only need java enabled on the browser of the sharing computer, and the viewing computers just need a browser.  That’s great when trying to share your screen with people in a restricted environment. and issues with Mac OSX

I ran across a great site today for people with kids or just want to filter traffic on their network.  I have 3 kids and I just bought my 5 and 3 year old a macbook to share.  When I ran across I thought wow this would be a great time to do some filtering to keep them from coming across something they shouldn’t.

Use OpenDNS

It’s very simple to create an account and set it up since it is based on DNS.  Since it is based on DNS it is easy to work around, but I figure it will be a few years before my kids get to that point.

One issue I ran into though is their documentation for the Mac is based on a wired ethernet connection.  Who uses patch cables at home anymore?  Luckily I found a link to a site that shows how to get around this on the Mac.  You can read about hit here:

Sorting a loop in bash and other possibilites

As I said in my previous post, I learned a couple things about bash today. I had a nice for loop that outputted the info I wanted, but not in the right order. I thought to myself, man if this were php I would just put it in an array and sort it before looping across it. I bet this will be a pain in bash.

BUT, I was pleasantly surprised to find out how simple this really was. If you want to perform an action the output of a loop in bash then you just pipe done into the fuction you want performed. See the example below.

for VAR in $VARS; do
done | sort -n

Cool, right?

Lineing up fields with BASH (or other programming languages)

Learned a couple things about bash today. I was wanting to print something out nicely, so I was using tabs to separate fields. As you know, nothing ever lines up if you do not have values very similar in size. So I was about to search Google for the problem when I had a moment of sheer brilliance. 🙂 I thought I’ll just concatenate a bunch of spaces on the end of the variable and then use cut to grab how many characters I want. I was very proud of myself, but then bash quickly humbled me by condensing all my spaces I had added to the variable.

So, back to the all knowing Google. Turns out you have to quote your variable when you use it if you don’t want bash to truncate the spaces. So I quoted my variable when using it and all is good.

BUFFER="$VAR                                                                "
NICE_VAR=`echo "$VAR" | cut -c -15`
echo "$VAR $VAR2"

Move Oracle data files

The procedure below will allow you to move Oracle data and redo files.

1. It is a good idea to make a backup of the directory you are moving just in case something goes horribly wrong. 🙂
# cp -rp {data_dir} {backup_dir}

2. log in as the oracle user
# su -l oracle

3. move the database files
# mv {data_dir} {new_data_dir}

4. Set SID, log into database.
# sqlplus /nolog
SQL> connect /as sysdba;

5. Create pfile from spfile
SQL> create pfile from spfile;

6. In another terminal, modify the newly created pfile. It is usually called init{SID}.ora and can be in different directories. Look in udump, dbs, and other directories until you find the newly created pfile. Check the date to make sure it is the one you are looking for. Now, fix the directories for the control_files variable.

7. Go back to the original terminal and create spfile from pfile;
SQL> create spfile from pfile;

8. Mount database.
SQL> startup mount;

9. Alter the database to look in the new location for the data files and redo logs. Below is an example. (Do this for all data and redo logs.)
SQL> alter database rename file ‘/home/oracle/oradata/{SID}/sysaux01.dbf’ to ‘/usr/local/app/oracle/oradata/{SID}/sysaux01.dbf’
SQL> alter database rename file ‘/home/oracle/oradata/{SID}/redo01.log’ to ‘/usr/local/app/oracle/oradata/{SID}/redo01.log’

10. Open database.
SQL> alter database open;

Now it should hopefully come up properly. You man want to shut it down and bring it up once more to make sure everything is working properly.

Dumping a mysql table to SQL

I usually use phpMyAdmin to dump my table to SQL, but sometimes it is easier to do it from the command line. Use the following syntax to dump a table to SQL.

mysqldump -p -e -c --add-drop-table -r table.sql dbname table

Warning: The –add-drop-table will cause it to drop the existing table when you import.

You can import this with the command

mysql -p dbname < table.sql

yum upgrades tip

When upgrading with yum I have started taking an rpm inventory before and after the upgrade.
Before Upgrade:

rpm -qa > BeforeUpgrade.txt

After Upgrade:

rpm -qa > AfterUpgrade.txt

Then I can compare them so that I know which packages were not upgraded and I can figure out why the did not upgrade.

cat BeforeUpgrade.txt AfterUpgrade.txt | sort | uniq -c | sort -n | grep "^\ *2"