- Create a local disk image with Disk utility, whatever the size
- Unmount it
- Move it to a given directory on the NAS
- Resize it to the size you want to give it
- Mount it
Monday, June 18, 2012
Tuesday, June 12, 2012
Wednesday, June 6, 2012
NO DATA FOUND error
Trap the NO_DATA_FOUND exception, and handle it.
BEGIN
SELECT ... INTO x_data
FROM ...
WHERE ...;
EXCEPTION
WHEN NO_DATA_FOUND THEN
x_data := NULL;
END;
Monday, June 4, 2012
Wednesday, May 30, 2012
Monday, May 14, 2012
Oracle select N latest entries
select * from (select * from monitor.at_process_log order by log_id desc)
where ROWNUM <=10;
To accomplish the equivalent to MySql:
select * from sometable order by name limit 20,10
AskTom proposes:
select * from (select a.*, ROWNUM rnum from
(select * from monitor.at_process_log order by log_id desc) a where rownum <= 20)
where rnum >= 10;
Wednesday, May 9, 2012
Thursday, May 3, 2012
Install Cisco VPN 4.8.02 on Fedora 14 (2.6.35)
- tar xvfz vpnclient-linux-x86_64-4.8.02.0030-k9.tar.gz
- cd vpnclient
- sudo ./vpn_install
- You will probably get failures. If you get failures:
- wget http://projects.tuxx-home.at/ciscovpn/patches/vpnclient-linux-2.6.24-final.diff
- patch < ./vpnclient-linux-2.6.24-final.diff
- This step shows failures, but I don't care (*)
- wget http://lamnk.com/download/vpnclient-linux-4.8.02-64bit.patch
- patch < ./vpnclient-linux-4.8.02-64bit.patch
- sed -i 's/^CFLAGS/EXTRA_CFLAGS/' Makefile
- wget http://lamnk.com/download/vpnclient-linux-2.6.31-final.diff
- patch < ./vpnclient-linux-2.6.31-final.diff
- sudo sed -i 's/const\ struct\ net_device_ops\ \*netdev_ops;/struct\ net_device_ops\ \*netdev_ops;/' `find /usr/src -name netdevice.h`
- Update interceptor.c like explained in (**)
- sudo ./vpn_install
- sudo /sbin/service vpnclient_init start
- Create a profile like in (***) and substitute values
- cp *.pcf /etc/opt/cisco-vpnclient/Profiles directory
- vpnclient connect site-name (site-name is the same as site-name.pcf)
[jerome@monster] > patch < ./vpnclient-linux-2.6.24-final.diff
patching file GenDefs.h
Hunk #1 succeeded at 105 with fuzz 2.
Hunk #2 succeeded at 122 (offset 2 lines).
patching file interceptor.c
Hunk #3 FAILED at 111.
Hunk #4 succeeded at 142 (offset 5 lines).
Hunk #5 FAILED at 364.
Hunk #6 FAILED at 921.
Hunk #7 FAILED at 949.
4 out of 7 hunks FAILED -- saving rejects to file interceptor.c.rej
(**)
Replace
static void interceptor_init(struct net_device *);
with
static
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
int
#else
int __init
#endif
interceptor_init(struct net_device *);
(***)
[main] Description=sample user profile Host=<x.x.x.x> AuthType=1 GroupName=<GroupName> GroupPwd=<GroupPwd> EnableISPConnect=0 ISPConnectType=0 ISPConnect= ISPCommand= Username=<Username> UserPassword=<UserPassword> SaveUserPassword=1 EnableBackup=0 BackupServer= EnableNat=1 CertStore=0 CertName= CertPath= CertSubjectName= CertSerialHash=00000000000000000000000000000000 DHGroup=2 ForceKeepAlives=1
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
Labels:
linux,
virtualbox
Wednesday, April 25, 2012
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
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
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
Subscribe to:
Posts (Atom)