14 Ekim 2009 Çarşamba

Calling External C or Java Procedures From Oracle PL/SQL

Follow this link for detailed documentation: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_extern_proc.htm

Briefly
  1. Load C procedures or Java Classes
    • To load C procedures,
      1. Set Up the Environment
        • set the parameter extproc by default, in the configuration files tnsnames.ora and listener.ora.
        • Start a listener process exclusively for external procedures.
        • If the agent will run in multithreaded mode, start the agent using the agent control utility startup command. In the OS shell prompt:
          agtctl startup extproc agent_sid
      2. Identify the DLL, using CREATE LIBRARY
      3. Publish the External Procedure, CREATE FUNCTION or CREATE PROCEDURE. For example:
        FUNCTION SEND(Host VARCHAR2, Port VARCHAR2, sMsg VARCHAR2, rMsg IN OUT VARCHAR2 ) RETURN BINARY_INTEGER AS EXTERNAL LIBRARY MYXXXLIB NAME "SendAndReceive" LANGUAGE C PARAMETERS (Host BY REFERENCE, Port BY REFERENCE, sMsg BY REFERENCE, rMsg BY REFERENCE);

2 Ekim 2009 Cuma

About Turkish Char Encodings

newStr = oldStr.replace("İ", "İ");
newStr = newStr.replace("ı", "ı");
newStr = newStr.replace("Ğ", "Ğ");
newStr = newStr.replace("ğ", "ğ");
newStr = newStr.replace("Ü", "Ü");
newStr = newStr.replace("ü", "ü");
newStr = newStr.replace("Ş", "Ş");
newStr = newStr.replace("ş", "ş");
newStr = newStr.replace("Ö", "Ö");
newStr = newStr.replace("ö", "ö");
newStr = newStr.replace("Ç", "Ç");
newStr = newStr.replace("ç", "ç");

or

newStr = oldStr.replace("İ", "\u0130");
newStr = newStr.replace("ı", "\u0131");
newStr = newStr.replace("Ğ", "\u011e");
newStr = newStr.replace("ğ", "\u011f");
newStr = newStr.replace("Ü", "\u00dc");
newStr = newStr.replace("ü", "\u00fc");
newStr = newStr.replace("Ş", "\u015e");
newStr = newStr.replace("ş", "\u015f");
newStr = newStr.replace("Ö", "\u00d6");
newStr = newStr.replace("ö", "\u00f6");
newStr = newStr.replace("Ç", "\u00c7");
newStr = newStr.replace("ç", "\u00e7");

or

newStr = oldStr.replace("İ", "\xDD");
newStr = newStr.replace("ı", "\xFD");
newStr = newStr.replace("Ğ", "\xD0");
newStr = newStr.replace("ğ", "\xF0");
newStr = newStr.replace("Ü", "\xDC");
newStr = newStr.replace("ü", "\xFC");
newStr = newStr.replace("Ş", "\xDE");
newStr = newStr.replace("ş", "\xFE");
newStr = newStr.replace("Ö", "\xD6");
newStr = newStr.replace("ö", "\xF6");
newStr = newStr.replace("Ç", "\xC7");
newStr = newStr.replace("ç", "\xE7");

23 Eylül 2009 Çarşamba

my favorites for today

NewLISP home http://newlisp.nfshost.com/
  • It is an Lisp interpreter, not a compiler.
  • It is a new lisp dialect, in my opinion.
Cilk project (written in C) for multithreaded programming. http://supertech.csail.mit.edu/cilk/
  • Especially effective for exploiting dynamic, highly asynchronous parallelism, which can be difficult to write in data-parallel or message-passing style
  • A highly successful Cilk application is the Cilkchess computer chess program, which won first prize in the Dutch Open Computer Chess Championship in November 1996, and almost defended its title in 1997. Its predecessor *Socrates parallel chess program placed second in the ICCA 8th Computer Chess World Championship in Hong Kong, May 1995.

28 Ağustos 2009 Cuma

Some Ubuntu and FreeBSD tips

  • To exit from X11 press Ctrl+Alt+Backspace

  • To solve PS/2 mouse problem in Ubuntu:
    http://ubuntuforums.org/showthread.php?t=844968

  • FreeBSD network setup:
    In sysinstall
    • If FreeBSD is installed in Virtual PC (or another virtual desktop solutions)
      • run "ipconfig /all" (from Windows) or "ifconfig" (from Linux, or others)

        Take your IP address and change the last part with an unused value
        e.g. if ipconfig says that your is IP 10.222.38.5, you can use 10.222.38.100

        Use this value as IPv4 Address

      • Take the gateway address from "ipconfig in Windows" or "route in Linux".

        Use this value as IPv4 Gateway

      • Take the DNS server address from "ipconfig in Windows" or "cat /etc/resolv.conf in Linux".

        Use the first value as Nameserver

        You can add the other DNS server adresses into FreeBSD' s "/etc/resolv.conf" file after exiting sysinstall.

    • If FreeBSD is installed onto a home computer connected to a ADSL modem
      • Get IP address of your modem, it starts with "192.168." and ends with ".1" (e.g. 192.168.0.1, or 192.168.2.1)

        Use this value as IPv4 Gateway

      • take this IP address and change the last part with an unused value
        e.g. if ipconfig says that your is IP 10.222.38.5, you can use 10.222.38.100

        Use this value as IPv4 Address

31 Temmuz 2009 Cuma

CVS Client and Server installation on Ubuntu


Before installing the server, install the CVS Client:
   sudo apt-get install cvs

Then install the CVS server named "cvsd":
** If yo want to learn why we' ve chosen "cvsd", read this note,
   otherwise skip to the step 1 below:
      CVS was designed to use "xinetd" to startup service.
      But now most Linux distributions do not install xinetd by
      default, and configuration of CVS is somewhat complicated.
      "cvsd" is a wrapper program for CVS in pserver mode, it can
      startup CVS as a standalone daemon, under a special uid/gid
      in a chroot jail. It is relatively easy to use cvsd and its
      configuration file to setup CVS repositories.

       So, we' ve chosen "cvsd" instead of "xinetd"

1. Install the CVS Daemon named "cvsd" :

   sudo apt-get install cvsd

   When prompted for Repository, type in "/cvsrepo".


2. There is no need to add new group and new user !!!
   In the step1, the group 'cvsd' and the user
   'cvsd' have already been created.

3. If this is the last version of cvsd, skip this step.
   To update the cvsd:

   sudo cvsd-buildroot /var/lib/cvsd


4. If the folder /cvsrepo does not exist, then create it.

   sudo mkdir cvsrepo


5. Set the owner of /cvsrepo to cvsd:cvsd

   sudo chownn -R cvsd:cvsd /cvsrepo


6. Initialize the repository

   sudo cvs -d /var/lib/cvsd/cvsrepo init

30 Temmuz 2009 Perşembe

Installing Ubuntu & FreeBSD on the same computer

You can look at
http://forums.freebsd.org/archive/index.php/t-614.html

Briefly, you can choose one of 4 options :
1. (assuming Ubuntu is installed first) Use grub loader. Then add FreeBSD to menu.lst
2. use 3rd party boot managers such as GAG
3. use vmware or other virtual machine software
4. one says that lilo boot manager can easily be configured to support linux and FreeBSD. But grub is preffered by the most of users.

29 Temmuz 2009 Çarşamba

Using Oracle CREATE TABLE

I have prepared an example Oracle "create table" script with those characteristics:
  • compact, using "inline constraints", you can write
    more readable scripts. I preferred inline constraints instead
    of using "ALTER TABLE xxx ADD (PRIMARY KEY /
    CONSTRAINT...)" statements. Using GUI tools to create
    those scripts, we can easily miss more readable scripts.
  • several constraints such as "multiple column PRIMARY KEY",
    "REFERENCES (i.e. Foreign Key", "multiple column FOREIGN KEY", etc.
  • Options such as "ON DELETE SET NULL"
  • Several CHECK constraints
  • EXCEPTIONS INTO
  • and more...
DROP TABLE sa_dept CASCADE CONSTRAINTS;

CREATE TABLE sa_dept 
    employee_id     NUMBER(4)     PRIMARY KEY,

    last_name       VARCHAR2(10),

    email           VARCHAR2(100) NOT NULL UNIQUE,

    -- example for foreignkey const. with
    --   "different column names"
    --   (i.e, sa_dept.job_id = sa_jobs.id)
    -- of course, it is better to use the same
    --   column names if possible (sa_dept.job_id = sa_jobs.job_id)

    job_id          VARCHAR2(9)
                    CONSTRAINT fk_job
                    REFERENCES sa_jobs(id),

    -- ref. int. constr. with ON DELETE SET NULL
    manager_id      NUMBER(4)
                    CONSTRAINT fk_mgr
                    REFERENCES sa_employees ON DELETE SET NULL,

    -- composite foreignkey constr. + EXCEPTIONS INTO example
    hire_date       DATE
                    CONSTRAINT
                    FOREIGN KEY (employee_id, start_date)
                    REFERENCES sa_job_history(employee_id, start_date)
                    EXCEPTIONS INTO sa_wrong_emp,   -- sa_wrong_emp should exists!

    -- CHECK constr. Any boolean expression in
    -- parentheses after "CHECK" is valid

    salary          NUMBER(7,2)
                    CONSTRAINT check_sal
                    CHECK(salary * commission_pct <= 5000),

    -- CHECK constr. with BETWEEN. As stated above,
    -- any boolean expression in parentheses' after "CHECK" is valid.

    commission_pct  NUMBER(7,2)
                    CONSTRAINT check_divno
                    CHECK( BETWEEN10 AND 99)
                    DISABLE, -- if we use DISABLE, Oracle defines
                             -- the constr. but does not enable it.


    -- ref. int. constr. with ON DELETE CASCADE
    department_id   NUMBER(2)
                    CONSTRAINT fk_deptno
                    REFERENCES sa_departments(department_id) ON DELETE CASCADE

);

28 Temmuz 2009 Salı

Calling stored procedures from Lisp using CLSQL

I found a link describing how to call stored procedures from Lisp using CLSQL
http://www.rhinocerus.net/forum/lang-lisp/46000-clsql-stored-procedures.html

I have not tried the solution. When I try, I will explain it in details.

16 Temmuz 2009 Perşembe

Installing Emacs clisp and SLIME on Ubuntu

1. Install clisp and SLIME using Synaptic Package Manager.

2. According to SLIME User Manual some lines are required in .emacs file.
If you don't already have one, create a ".emacs" file in your HOME DIRECTORY. Add the following code to it, (the paths below are default for Ubuntu clisp and SLIME installations):
    (setq inferior-lisp-program "/usr/bin/clisp")
    (add-to-list 'load-path "/usr/share/emacs/site-lisp/slime")
    (require 'slime)
    (slime-setup)

Start up emacs, type "M-x slime" (i.e., Alt-x slime) and start hacking.

PS: With those instructions, I'd installed on Ubuntu 8.04 Hardy and Ubuntu 9.04 Jaunty Jackalope successfully.

14 Temmuz 2009 Salı

Let Over Lambda

Let Over Lambda by Doug Hoyte, (first 3 chapters and a good reference)

22 Haziran 2009 Pazartesi

examples about GNU CLISP Command Line parameters

Some examples about GNU CLISP Command Line parameters
  • -x expressions parameter:
    Executes a series of arbitrary expressions instead of a read-eval-print loop. The values of the expressions will be output to *STANDARD-OUTPUT*. Due to the argument processing done by the shell, the expressions must be enclosed in double quotes, and double quotes and backslashes must be escaped with backslashes.

    Example:
    clisp -x " (write-string \" Hello\") (write-string \" Hello\") "

10 Haziran 2009 Çarşamba

Some good Lisp tutorials

In addition to two classics, Paul Graham' s On Lisp and Peter Seibel' s Practical Common Lisp, I like two another e-books:
  • Basic Lisp Techniques, by David J. Cooper, March 19, 2003
  • Loving Lisp, by Mark Watson, 2002

POP3 hakkında güzel bir doküman

POP3 hakkında güzel bir doküman:
http://www.faqs.org/rfcs/rfc1939.html

23 Mayıs 2009 Cumartesi

gcc gives stdio.h not found error on Ubuntu

Problem: On Ubuntu Linux, when I try to compile a simple C code, it gives stdio.h not found error.

Solution: Install build-essential.
You can install it using either
  • "Synaptic Package Manager" in Sytem > Administration menu, or
  • sudo apt-get install build-essential command in the terminal window.

6 Mart 2009 Cuma

Günün sözü

Distinquish between activity and productivity.

21 Ocak 2009 Çarşamba

CSS: Toggle visibility on hover (with IE6 fix)

CSS: Toggle visibility on hover

As IE 6.0 fix #fix a:hover { zoom: 1; } is added.

7 Ocak 2009 Çarşamba

Getting HTML contents of YUI Rich Editors

//Put the HTML back into the text area 
myEditor.saveHTML(); 

//The var html will now have the contents of the textarea
var html = myEditor.get('element').value;

//We got the contents, if we want format for alert() func:
html = html.replace(/<br>/gi, "<br>\n"); 
alert(html);

6 Ocak 2009 Salı

Çok güzel bir Emacs tutorial - Türkçe

Aycan İrican' dan çok güzel bir Türkçe Emacs tutorial.

http://people.core.gen.tr/~aycan.irican/web/publish/NasilBirEmacs.html

İngilizce tutorial' larda bile bulamayacağınız bilgiler burada gayet güzel bir dille anlatılıyor.

Emacs' ta e-posta, IRC, MSN, fihrist, ielm(REPL buffer for elisp), slime vb kurulup çalıştırılması, örnek bir Lisp Tabanlı Web Uygulama Sunucusu kurulumu, bu sunucuya swank ile uzaktan erişim dahi anlatılmış.

Bu kadar güzel bir dökümanda küçük bir eksik var. Windows kurulumları yok. Çok az Windows kullanıcısı Emacs kullanır ama ben de bunlardan birim :(

5 Ocak 2009 Pazartesi

Regular Expressions in Lisp

  • When POSIX regular expressions module is present, *FEATURES* contains the symbol :REGEXP.
  • When Perl Compatible regular expressions (PCRE) module is present, *FEATURES* contains the symbol :PCRE.