Monday, September 24, 2012

Discard all unstaged files in git

> git checkout -- .

Wednesday, September 12, 2012

Restoring a directory from history

> git checkout a44d627 -- .metadata/

Friday, August 31, 2012

Oracle views vs. materialized views

  • Materialized views are disk based and updated periodically base upon the query definition.
  • Views are virtual only and run the query definition each time they are accessed.

Thursday, August 23, 2012

Count rows in partition

SELECT table_name,
partition_name,
high_value,
num_rows
FROM all_tab_partitions
ORDER BY table_name, partition_name;

Monday, July 2, 2012

Git label

 git tag  EXTRANET_v2.1 04b7f86

VirtualBox Guest additions upgrade: install_x11_startup_app: no script given

Here's what we get after trying to upgrade the Guest Additions from 4.1.12 to 4.1.14:
Installing the Window System drivers
Installing X.Org Server 1.11 modules ...done.
Setting up the Window System to use the Guest Additions ...done.
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services components ...fail!
(See the log file /var/log/vboxadd-install-x11.log for more information.)
Press Return to close this window...

install_x11_startup_app: no script given
Before installing the new guest additions version, you need to remove manually 2 symlinks:
 rm /usr/lib64/VBoxGuestAdditions
 rm /usr/share/VBoxGuestAdditions

Monday, June 18, 2012

Have ALC887 work on Lion 10.7.4

Follow the instructions on https://tonymacx86.com/viewtopic.php?f=16&t=59061 for installing 887_v100302

Using my NAS with Final Cut Pro X

  1. Create a local disk image with Disk utility, whatever the size
  2. Unmount it
  3. Move it to a given directory on the NAS
  4. Resize it to the size you want to give it
  5. Mount it

Tuesday, June 12, 2012

Sending POST with cURL

curl -d "param1=value1&param2=value2" http://example.com/resource.cgi

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

Get time elapsed of an SQL query

In SQL plus, use:
SQL> set timing on;

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

Which Yum package provides this missing library?

yum whatprovides */libXext.so.6

Thursday, May 3, 2012

Install Cisco VPN 4.8.02 on Fedora 14 (2.6.35)

  1. tar xvfz vpnclient-linux-x86_64-4.8.02.0030-k9.tar.gz
  2. cd vpnclient
  3. sudo ./vpn_install
  4. You will probably get failures. If you get failures:
  5. wget http://projects.tuxx-home.at/ciscovpn/patches/vpnclient-linux-2.6.24-final.diff
  6. patch < ./vpnclient-linux-2.6.24-final.diff
  7. This step shows failures, but I don't care (*)
  8. wget http://lamnk.com/download/vpnclient-linux-4.8.02-64bit.patch
  9. patch < ./vpnclient-linux-4.8.02-64bit.patch
  10. sed -i 's/^CFLAGS/EXTRA_CFLAGS/' Makefile
  11. wget http://lamnk.com/download/vpnclient-linux-2.6.31-final.diff
  12. patch < ./vpnclient-linux-2.6.31-final.diff
  13. sudo sed -i 's/const\ struct\ net_device_ops\ \*netdev_ops;/struct\ net_device_ops\ \*netdev_ops;/' `find /usr/src -name netdevice.h`
  14. Update interceptor.c like explained in (**)
  15. sudo ./vpn_install
  16. sudo /sbin/service vpnclient_init start
  17. Create a profile like in (***) and substitute values
  18. cp *.pcf /etc/opt/cisco-vpnclient/Profiles directory
  19. 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

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;