Thursday, January 31, 2008

Oracle MV Update

I love materialized views, but sometimes you need to be able to force their update. Just use the following Pl/SQL (I like using it from APEX where users need the ability to force the refresh

BEGIN
DBMS_MVIEW.REFRESH('NEWPORT.TRANSACTIONS_MV','C');
END;

Tuesday, January 29, 2008

Setting TimeZone in linux

If you look in the /usr/share/zoneinfo directory you'll see all the available time zone settings. To change it just create a symlink from /etc/localtime to the correct zone file. (Reference)

mv /etc/localtime ~/localtime.old
ln -s /usr/share/zoneinfo/America/Denver /etc/localtime
If you want to sync your hardware clock run the following.
/sbin/hwclock  --systohc

UnBlocking Attachments in Outlook

Outlook blocks a lot of usefull extensions by default, like mdb files.

You can unblock them though. (Full directions)

The meet of it comes down to:
  1. Run Regedit, and go to this key:

    HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security (change 10.0 to 9.0 for Outlook 2000 SP3 or to 11.0 for Outlook 2003)
  2. Under that key, add a new string value named Level1Remove.
  3. For the value for Level1Remove, enter a semicolon-delimited list of file extensions. For example, entering this:

    .mdb;.url

    would unblock Microsoft Access files and Internet shortcuts. Note that the use of a leading dot was not previously required, however, new security patches may require it. If you are using "mdb;url" format and extensions are blocked, add a dot to each extension. Note also that there is not a space between extensions.
After that, restart outlook and enjoy. Personaly i've only unblocked .mdb so far.

Monday, January 28, 2008

Embedded vi Syntax Highlighting


This is a vi syntax highlighting trick gmax
emailed to me. It changes the syntax highlighting for here documents and the
qq() and q() operators as long as braces {} are used to delimit them (that is the trick, you see). This example
'embeds' the MySQL highlighting scheme inside Perl code. Example.


Find the perl.vim file that is being used by your version of vi, usually somewhere
in /usr/share/vim/


Add this syntax to it:


syn include @Sql <sfile>:p:h/mysql.vim
syn region perlSQL start="qq{" end="}" contains=@Sql keepend
syn region perlSQL start="q{" end="}" contains=@Sql keepend
syn region perlSQL start="<<MYSQL" end="^MYSQL" contains=@Sql keepend

just before this line at the end of the file:
let b:current_syntax = "perl"

and save this file [mysql.vim] to the same directory
as the file you just edited (perl.vim).


Configure Apt-get to use Web

I was having trouble with apt-get wanting a CD-ROM. This was inside a Nagios VMware appliance so I didn't have the CD. apt-get appears to default to using the cd, all you need to do is edit /etc/apt/sources.list and comment out the first line. Then uncomment one of the web address lines, in my file they where nicely commented so my final file looked like:


#deb cdrom:[Debian GNU/Linux 3.1 r1 _Sarge_ - Official i386 Binary-1 (20051218)]/ unstable contrib main
deb file:/root debs/
#deb http://security.debian.org/ stable/updates main contrib
deb http://debian.oregonstate.edu/debian/ stable main
#deb http://debian.oregonstate.edu/debian/ unstable main

A quick 'apt-get update' and I was in business.

Setting up Remote SSH with shared keys

This little bit of code is quite nice. I put it in a file called setup_ssh in my ~/bin directory and life was much easier. Now when I want to setup shared key authentication i just type 'setup_ssh user@host' and put in my password. Thats it!

#!/bin/bash
cat ~/.ssh/id_rsa.pub | ssh $1 'mkdir -p .ssh; cat >> .ssh/authorized_keys'