Wednesday, December 3, 2008

How to sync Google Contacts and Calendar with iPhone

I've been looking for some simple solution to sync Google Contacts & Calendar with my iPhone on the air (without syncing with my notebook). Finally I found a solution that seems to be working like a charm.



Setup process is quite simple and straigh forward. 

Friday, August 22, 2008

cfmenu and cfgrid overlap

If you are using <cfmenu> and <cfgrid> and you have an overlapping of the menu items by cfgrid header (a part of menu is hidden behind cfgrid header) you must add to your CSS a following style:


#myMenuId .yuimenu {
z-index: 300003;
}

This problem is caused by some "yui" CSS style with z-index set to 1, while grid related styles have z-index bigger than 200000.

Friday, July 25, 2008

ESX host not connecting to Virtual Center

We got following problem some days ago:

One of our ESX (version 3.5) hosts, after crash, was not connecting to Virtual Center (version 2.5).

Solution:
  • Restart management service on ESX host
service mgmt-vmware stop
service mgmt-vmware start
  • Restart Virtual Center service on Virtual Center server (stop/start on service VMware Virtual Center in Services)

One more stuff - if you have a lot of memory on your hosts (16 GB or more) I would recommend you to increment amount of console memory on your host to 800 MB. You can do this in "Configuration" tab for host in your Virtual Center console.

Wednesday, June 25, 2008

Creating a copy of the disk (vmdk) in VMware

When you need to have the a copy of the disk from one VM on the other:

  • Power off  source VM, copy your .vmdk files to destination VM (probably you would like to change disk name and flat name - just rename your files and edit smaller .vmdk file to set correct name for flat file).
  • Set new UUID for your copy of your original .vmdk file
/usr/sbin/vmkfstools -J setuuid path_to_destination_VM/filename.vmdk
  • Add new disk to your destination VM (using "Use an existing virtual disk" option)
  • Start your VMs (source and destination)
  • Mount new drive on your destination machine
We used this solution to make a quick copy of data files disks from primary Oracle server to standby Oracle server.

Monday, June 16, 2008

Oracle analog of MySQL GROUP_CONCAT function

I was looking for Oracle analog of MySQL GROUP_CONCAT function. There is a solution on Ask Tom site. So here it is:


create or replace type string_agg_type as object (
  total varchar2(4000),

  static function ODCIAggregateInitialize(sctx IN OUT string_agg_type )
  return number,

  member function ODCIAggregateIterate(self IN OUT string_agg_type, value IN varchar2 )
  return number,

  member function ODCIAggregateTerminate(self IN string_agg_type, returnValue OUT varchar2, flags IN number)
  return number,

  member function ODCIAggregateMerge(self IN OUT string_agg_type, ctx2 IN string_agg_type)
  return number
);
/

create or replace type body string_agg_type is
  static function ODCIAggregateInitialize(sctx IN OUT string_agg_type)
  return number
  is
  begin
    sctx := string_agg_type( null );
    return ODCIConst.Success;
  end;

  member function ODCIAggregateIterate(self IN OUT string_agg_type, value IN varchar2 )
  return number
  is
  begin
    self.total := self.total || ',' || value;
    return ODCIConst.Success;
  end;

  member function ODCIAggregateTerminate(self IN string_agg_type, returnValue OUT varchar2, flags IN number)
  return number
  is
  begin
    returnValue := ltrim(self.total,',');
    return ODCIConst.Success;
  end;

  member function ODCIAggregateMerge(self IN OUT string_agg_type, ctx2 IN string_agg_type)
  return number
  is
  begin
    self.total := self.total || ctx2.total;
    return ODCIConst.Success;
  end;
end;
/

create or replace function stragg(input varchar2)
return varchar2
parallel_enable aggregate using string_agg_type;
/

After this you can use this function like this:
select t1.id, stragg(t2.name) as names from table1 t1, table2 t2 where t1.id=t2.id group by t1.id;

It will produce comma separated list of the names - something like this:
ID NAMES
-- ------------------------------------
10 CLARK,KING,MILLER
20 SMITH,FORD,ADAMS,SCOTT,JONES
30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD

Tuesday, May 13, 2008

List number of file handles (open files) for each process

Here is a simple script that will show you a number of file handles (open files) used by each process on your Linux system:


ps -e|grep -v TTY|awk {'print "echo -n \"Process: "$4"\tPID: "$1"\tNumber of FH: \"; lsof -p "$1"|wc -l"'} > out; . ./out

Monday, April 28, 2008

& in Oracle insert or update statements

If you have & or % in your Oracle insert or update statements - you probably would like to do the following:


SQL> set define off
SQL> [your insert or update query containing & and %]
SQL> set define on

Wednesday, April 23, 2008

Export from Oracle table to CSV file

Sometimes you need to export result of the query to CSV file. Here is a nice example of how to do this kind of operations.


SQL> SET LINESIZE 500 FEEDBACK OFF TRIMSPOOL ON TERMOUT OFF HEAD OFF PAGESIZE 0 TERM OFF
SQL> spool outfile.csv
SQL> select '"'|| column_1 || '",' || column_2 || ',' || column_3 from mytable where [your where statement]
...
...
SQL> spool off
SQL> exit

In this case column_1 data will be surrounded by "" (you may need this if you have , character in field data).

Update: SET LINESIZE determines a maximum number of characters in the line. So if you expect output bigger than 500 lines you must set this to a bigger value.

Tuesday, April 8, 2008

Cent OS 5.1 + Oracle 10g

Apart of modifying /etc/redhat-release to "redhat-4", there are a couple of packages that you will need to install in order to make Oracle 10g work with Cent OS 5.1:


yum install \
compat-db-4.2.52-5.1 \
glibc-devel-2.5-18.el5_1.1 \
libX11-devel-1.0.3-8.0.1.el5 \
libXau-devel-1.0.1-3.1 \
libXdmcp-devel-1.0.1-2.1 \
libXmu-1.0.2-5 \
libXtst-devel-1.0.1-3.1 \
mesa-libGL-devel-6.5.1-7.5.el5 \
openmotif-2.3.0-0.3.el5 \
xorg-x11-proto-devel-7.1-9.el5.centos

Wednesday, February 20, 2008

Mac OS & Database development

Since switching to Mac I was looking for good DB modeling/editing tool that will support Oracle and MySQL databases. Finally I got one...

 
 
Seems to be a really nice tool.

Wednesday, February 13, 2008

Leopard terminal and Midnight Commander

If you use mc while connected to some linux server and you need to select some files - use Ctrl+T

Thursday, January 31, 2008

Perl: CPAN or RPM packages?

Maybe this is just CentOS 5.1 related issue, but...
 
For those of you who will install MailScanner - just a small tip to avoid problems. Spend some time and install required perl modules from CPAN. This will save you some time on fixing SpamAssassin and some other perl modules.

Tuesday, January 22, 2008

Manually configure Enterprise Manager Console

Run emca -config dbcontrol db and follow the instructions.

Monday, January 21, 2008

Redo log size & performance

We got a performance issue with our Oracle 10g. Suddenly the performance was going down and we was getting a significant increase on wait times. After sniffing around and asking a friend we found that:

  1. All our performance pick were related with time when our Oracle was writing the archive log.
  2. There is a direct relationship between log_buffer, redo log file size and performance.
So, here is a tip. Your redo log file size must be multiple by 2 of your log_buffer. What I mean is that if your log_buffer is 5 MB your redo log file size can be 10 MB (2 x 5 MB), 20 MB (4 x 5 MB), 30 MB (6 x 5 MB) and so on...

Wednesday, January 16, 2008

Ctrl+click with two fingers

Enable Ctrl+click with two fingers click in System Preferences -> Keyboard & Mouse -> Trackpad -> Tap trackpad using two fingers for secondary click. Believe me, it's quite comfortable.

List of all Max OS X keyboard shortcuts

Will be useful for all Mac users. A kind of 'print-it-and-put-in-front-of-you-until-you-remember'.


Taking screenshots in Leopard

To take a screenshot in Leopard just press Cmd + Shif + 3 if you want to take a full screen or Cmd + Shift + 4 if you want to take a screenshot of some region.

 
Cmd + Shift + 3 or 4 will make the same, but instead of saving a PNG file to your Desktop will copy a screenshot to clipboard.
 
After pressing Cmd + Shit + 4 you can use:
  • Spacebar - to take a screenshot of window (active or background)
  • Shift - to lock your region horizontally or vertically
  • Option - to resize your region proportionally

Reverse tunnel with SSH

When you need to create a reverse tunnel with SSH, just use the following:

 
ssh -R PORT_ON_REMOTE_SERVER:localhost:PORT_ON_LOCAL_SERVER -l LOGIN REMOTE_SERVER

Sun to acquire MySQL

There is a bunch of people who thinks that MySQL is a kind of database that is being used just for small projects. For those of you - take a look here. 1 billion USD for a small projects database solution? And if you still don't consider MySQL as possible database solution for your "serious" project - take a look here and here.

More comfortable environment

After installing new Linux or Unix system I like to edit /etc/profile or $HOME/.bash_profile and add following lines:

 
alias vi="vim -o"
alias ll="ls -l"
alias la="ls -la"
export EDITOR=vi
 
First line is to use vim instead of vi. Second and third lines will create two aliases for ls -l and ls -la commands. And forth line is to use vi always as system editor. 
 
YES, I love vi!

Show archive logfiles sequence

Quick SQL to see if your archive log had been applied:
 
SELECT SEQUENCE#, APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

Manually register new archive log

If you need to register archive log in Oracle by hand:

 
alter database register logfile '/some_direcotry/some_file.arc';

Rebooting linux without reboot command

Just a sample of how you can reboot or shutdown linux without issuing reboot command, so called hard reboot. That means that system will just make a reset as if you pressed a reset button, without running any shutdown scripts, etc. A kind of dangerous staff, but can be helpful in some occasions.


echo 1 > /proc/sys/kernel/sysrq 
echo b > /proc/sysrq-trigger
 
If you want to force shutdown machine try this.

echo 1 > /proc/sys/kernel/sysrq
echo o > /proc/sysrq-trigger

Perl inline replacement

Sometimes you need to replace something in a bunch of files. And this something is quite complex, so you can describe it only with regular expressions, or, by some other reason you need to use perl in your replacement string. Here is a small sample I'm using:

perl -p -i -e "s/SEARCH_STRING/REPLACEMENT_STRIGN/g"