Friday, April 27, 2012

PL/SQL: loop on array

In package:
    TYPE varchar2_array_type IS TABLE OF VARCHAR2(100) INDEX BY PLS_INTEGER;
In package body:
ze_or_keys varchar2_array_type;
BEGIN
    FOR i in 1 .. ze_or_keys.count
    LOOP
        IF i != 1 THEN
            my_string := my_string || ' OR ';
        END IF;
        my_string := my_string || ze_or_keys(i) || '=''' || ze_or_values(i) || '''';
    END LOOP;
END;

PL/SQL: loop on associative array

In package:
TYPE hash_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(100);
In package body:
ze_assoc hash_type;
BEGIN
    my_col_name := ze_assoc.first;
    LOOP
        EXIT WHEN my_col_name is null;
        my_string := my_string || ' OR ' || my_col_name || '=' || ze_assoc(my_col_name);
        my_col_name := ze_assoc.next(my_col_name);
    END LOOP;
END;

Thursday, April 26, 2012

Force resync of VirtualBox guest

E.g. To force time sync every 10 sec.:
VBoxService --timesync-set-threshold 10000

Wednesday, April 25, 2012

Log sqlplus output

SQL> spool /tmp/log.txt
SQL> @/tmp/toto.sql
SQL> spool off

Use ampersand (&) in strings with Oracle

set define off;

Remove invisible ^M from .csv

CTRL-x <RET> f iso-8859-1-unix <RET>
This matches the
M-x set-buffer-file-coding-system
function.

Friday, April 20, 2012

git diff same file between 2 commits

Say .git is in ~/src.
cd ~/src
git diff fc20f9f c52bb9c -- perl/file_manager/bin/fm_extract_cdr.pl

.htaccess ignored in public_html

Check that public_html has
AllowOverride All
in httpd.conf

Monday, April 9, 2012

Finding and Purging Big Files From Git History

The "Removing Objects" section from Pro Git chapter 9 explains how to do it.

Friday, April 6, 2012

Extend partition on CentOS

If you extend the size of a Virtual Machine (e.g. VMWare) hosting CentOS, you need to tell CentOS to use the additional space.
Check the existing partition table
[root@test ~]# fdisk -l /dev/sda

Disk /dev/sda: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d30cf

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       13055   104344576   8e  Linux LVM
/dev/sda3           13055       26109   104857600   83  Linux
Add a new partition
[root@test ~]# fdisk /dev/sda
  n {new partition}
  p {primary partition}
  4 {partition number}

  t {change partition id}
  8e {Linux LVM partition}
  w
Reboot
[root@test ~]# reboot
Check the new partition table
[root@test ~]# fdisk -l /dev/sda

Disk /dev/sda: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d30cf

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       13055   104344576   8e  Linux LVM
/dev/sda3           13055       26109   104857600   83  Linux
/dev/sda4           26109       39162   104853565   8e  Linux LVM
Create a new physical volume from the new partition
[root@test ~]# pvcreate /dev/sda4
Extend the existing volume group
[root@test ~]# vgextend vg_test /dev/sda4
NB: The volume group name is given by lvdisplay:
[root@test ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg_test/lv_root
  VG Name                vg_test
  LV UUID                wkJfwT-hJkJ-fQCL-HTqP-0ZrZ-i8vL-TrLTif
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                149.99 GiB
  Current LE             38398
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
...
Extend the logical volume
[root@test ~]# lvextend /dev/vg_test/lv_home /dev/sda4
Resize the filesystem in the logical volume
[root@test ~]# resize2fs /dev/vg_test/lv_home
Check that the new space has ben taken into account
[root@test ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_test-lv_root
                      148G  6.4G  134G   5% /
tmpfs                1002M     0 1002M   0% /dev/shm
/dev/sda1             485M   68M  392M  15% /boot
/dev/mapper/vg_test-lv_home
                      144G  5.0G  132G   4% /home
[root@test ~]# 

Tuesday, April 3, 2012