Wednesday, 29 December 2010
Printing Large HTML tables on multiple pages
Try this:
1. Create a HTML document with the following code:
2. Note the use of thead, tbody and tfoot.
3. I have tested it on Firefox, IE8.
Thanks...
Friday, 3 December 2010
Setting Up an MPI Cluster on Ubuntu...
1. Install OpenMPI on all machines.
$sudo apt-get install libopenmpi-dev openmpi-bin openmpi-doc
2. Installing openSSH on all machines.
$sudo apt-get install openssh-server openssh-client
3. Select one Master machine say M and others will be slaves say S.
4. Now we need to make sure M can logon to all S machines with out a password.
Create a user with same name on all machines. Say 'fawad'.
Login on M using 'fawad' and generate public/private key pair.
$ssh-keygen -t dsa
This command will generate id_dsa and id_dsa.pub files in ~/.ssh folder. id_dsa is the private key and id_dsa.pub is the public key. Now we need to keep the private key and copy the public key on to all the slaves machines.
5. Use scp to copy id_dsa.pub in the home directory of fawad on all S machines.
6. On the S machines do:
Login as fawad.
$cd ~/.ssh
$ cat id_dsa.pub >> authorized_keys
7. Now the M machine will be able to logon to all machines without password.
8. On the M machines.
Write a MPI code and save it. In my case i used the following code and saved it in hello_nodes.c
--------------hello_nodes.c--------------------
/*
A simle example program using MPI - Hello World
The program consists of one receiver process and N-1 sender
processes. The sender processes send a message consisting
of their hostname to the receiver. The receiver process prints
out the values it receives in the messages.
Compile the program with 'mpicc hello_nodes.c -o hello_nodes'
To run the program on four processors do 'mpiexec -n 4 ./hello'
*/
#include
#include
#include
int main(int argc, char *argv[]) {
const int tag = 42; /* Message tag */
int id, ntasks, source_id, err, i;
MPI_Status status;
char msg[80]; /* Message array */
err = MPI_Init(&argc, &argv); /* Initialize MPI */
if (err != MPI_SUCCESS) {
printf("MPI_init failed!\n");
exit(1);
}
err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks); /* Get nr of tasks */
if (err != MPI_SUCCESS) {
printf("MPI_Comm_size failed!\n");
exit(1);
}
err = MPI_Comm_rank(MPI_COMM_WORLD, &id); /* Get id of this process */
if (err != MPI_SUCCESS) {
printf("MPI_Comm_rank failed!\n");
exit(1);
}
/* Check that we run on at least two processors */
if (ntasks < 2) {
printf("You have to use at least 2 processors to run this program\n");
MPI_Finalize(); /* Quit if there is only one processor */
exit(0);
}
/* Process 0 (the receiver) does this */
if (id == 0) {
int length;
MPI_Get_processor_name(msg, &length); /* Get name of this processor */
printf("Hello World from process %d running on %s\n", id, msg);
for (i=1; i
&status); /* Receive a message from any sender */
if (err != MPI_SUCCESS) {
printf("Error in MPI_Recv!\n");
exit(1);
}
source_id = status.MPI_SOURCE; /* Get id of sender */
printf("Hello World from process %d running on %s\n", source_id, msg);
}
}
/* Processes 1 to N-1 (the senders) do this */
else {
int length;
MPI_Get_processor_name(msg, &length); /* Get name of this processor */
err = MPI_Send(msg, length+1, MPI_CHAR, 0, tag, MPI_COMM_WORLD);
if (err != MPI_SUCCESS) {
printf("Process %i: Error in MPI_Send!\n", id);
exit(1);
}
}
err = MPI_Finalize(); /* Terminate MPI */
if (err != MPI_SUCCESS) {
printf("Error in MPI_Finalize!\n");
exit(1);
}
if (id==0) printf("Ready\n");
exit(0);
}
-------------------------------------------
9. Compile the code.
$ mpicc hello_nodes.c -o hello_nodes
10. Run the code on the same machine.
fawad@fawad-virtual-machine:~$ mpirun -np 4 hello_nodes
Hello World from process 0 running on fawad-virtual-machine
Hello World from process 2 running on fawad-virtual-machine
Hello World from process 1 running on fawad-virtual-machine
Hello World from process 3 running on fawad-virtual-machine
Ready
11. Create a file called hostfile, which contains the slave computers in the MPI cluster:
fawad@fawad-virtual-machine:~$ cat hostfile
172.16.92.130
172.16.92.129
12. Copy the source code hello_mpi to all slave machines using scp.
13. Then run the following command to run the job on all slave machines:
fawad@fawad-virtual-machine:~$ mpirun --hostfile hostfile -np 10 hello_nodes
Hello World from process 0 running on ubuntu
Hello World from process 6 running on ubuntu
Hello World from process 4 running on ubuntu
Hello World from process 8 running on ubuntu
Hello World from process 3 running on fawad-virtual-machine
Hello World from process 2 running on ubuntu
Hello World from process 9 running on fawad-virtual-machine
Hello World from process 5 running on fawad-virtual-machine
Hello World from process 7 running on fawad-virtual-machine
Hello World from process 1 running on fawad-virtual-machine
Ready
DONE :).
Now the next step is that we need to try creating a NFS so that we do not have to copy the binary file all the time.
Wednesday, 1 December 2010
Finding and killing an Oracle session...
------------------
SELECT USERNAME, OSUSER, MACHINE, SID, SERIAL#, STATUS, SECONDS_IN_WAIT
from v$session
WHERE
TYPE != 'BACKGROUND'
AND username = 'STAN4'
order by seconds_in_wait desc
Killing a session:
------------------
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
Tuesday, 30 November 2010
Java Regex...
import java.util.regex.*;
public class SampleRegex
{
public static void main(String[] params)
{
Pattern pattern = Pattern.compile("(.*):(.*)");
Matcher matcher = pattern.matcher(params[0]);
if(matcher.matches())
{
System.out.print("Key:");
System.out.println(matcher.group(1));
System.out.print("Value:");
System.out.println(matcher.group(2));
}
else
System.out.print("No match");
}
}
Further reading links:
1. http://www.developer.com/article.php/1460561
2. http://download.oracle.com/javase/tutorial/essential/regex/
Friday, 26 November 2010
do While Loop PL/SQL Oracle...
SQL> declare
2 n_num number := 1;
3 begin
4 loop
5 dbms_output.put(n_num||', ');
6 n_num := n_num + 1;
7 exit when n_num > 5;
8 end loop;
9 dbms_output.put_line('Final: '||n_num);
10 end;
11 /
For details visit: http://www.dba-oracle.com/concepts/pl_sql_repeat_until_loop.htm
Matching Date in Sed: A Filename comparison example....
Output: Matched
Wednesday, 24 November 2010
SED : Tutorial 2
echo "Fawad 123 Hello How are you" | sed s/H.*//
Output: Fawad 123
Double Substitution
$ echo "Fawad is a friend of Nazir" | sed 's/Fawad/Midhat/g;s/Nazir/Fawad/g'
Output: Midhat is a friend of Fawad
Matching Exact Patterns using [ and ].
$ echo "Aaminah is a name" | sed s/[aA][aA]/BB/g
Output: BBminah is a name
REF: http://www.grymoire.com/Unix/Regular.html
Regular Expression Matches
[] The characters "[]"
[0] The character "0"
[0-9] Any number
[^0-9] Any character other than a number
[-0-9] Any number or a "-"
[0-9-] Any number or a "-"
[^-0-9] Any character except a number or a "-"
[]0-9] Any number or a "]"
[0-9]] Any number followed by a "]"
[0-9-z] Any number,
or any character between "9" and "z".
[0-9\-a\]] Any number, or
a "-", a "a", or a "]"
Matching a specific number of sets with \{ and \}
Regular Expression Matches
_
* Any line with an asterisk
\* Any line with an asterisk
\\ Any line with a backslash
^* Any line starting with an asterisk
^A* Any line
^A\* Any line starting with an "A*"
^AA* Any line if it starts with one "A"
^AA*B Any line with one or more "A"'s followed by a "B"
^A\{4,8\}B Any line starting with 4, 5, 6, 7 or 8 "A"'s
followed by a "B"
^A\{4,\}B Any line starting with 4 or more "A"'s
followed by a "B"
^A\{4\}B Any line starting with "AAAAB"
\{4,8\} Any line with "{4,8}"
A{4,8} Any line with "A{4,8}"
Matching words with \< and \>
Searching for a word isn't quite as simple as it at first appears. The string "the" will match the word "other". You can put spaces before and after the letters and use this regular expression: " the ". However, this does not match words at the beginning or end of the line. And it does not match the case where there is a punctuation mark after the word.
There is an easy solution. The characters "\<" and "\>" are similar to the "^" and "$" anchors, as they don't occupy a position of a character. They do "anchor" the expression between to only match if it is on a word boundary. The pattern to search for the word "the" would be "\<[tT]he\>". The character before the "t" must be either a new line character, or anything except a letter, number, or underscore. The character after the "e" must also be a character other than a number, letter, or underscore or it could be the end of line character.
Backreferences - Remembering patterns with \(, \) and \1
Another pattern that requires a special mechanism is searching for repeated words. The expression "[a-z][a-z]" will match any two lower case letters. If you wanted to search for lines that had two adjoining identical letters, the above pattern wouldn't help. You need a way of remembering what you found, and seeing if the same pattern occurred again. You can mark part of a pattern using "\(" and "\)". You can recall the remembered pattern with "\" followed by a single digit. Therefore, to search for two identical letters, use "\([a-z]\)\1". You can have 9 different remembered patterns. Each occurrence of "\(" starts a new pattern. The regular expression that would match a 5 letter palindrome, (e.g. "radar"), would be
\([a-z]\)\([a-z]\)[a-z]\2\1
Examples:
1. Remember a pattern
$ echo "Aaminah Aaminah is a name" | sed 's/\(A[a-z]*\) \1/\1/g'
Output: Aaminah is a name
2. Eliminate the repeating characters.
$ echo "mmmmy nnname iis ffawad." | sed 's/\([a-z]\)\{1,3\}\1/\1/g'
Output: my name is fawad.
3. Keep first word and delete the rest.
$ echo "mmmmy nnname iis ffawad." | sed 's/\([a-z]*\).*/\1/'
Output: mmmmy
3. Printing the Last name & replacing the first name with last.
$ echo "Mr. Fawad Nazir" | sed 's/\([Ff]awad\) \([Nn]azir\)/\2 \1/'
Output: Mr. Nazir Fawad
$ echo "Mr. Fawad Nazir" | sed 's/\([Ff]awad\) \([Nn]azir\)/\2/'
Output: Mr. Nazir
3. Subtituting exact match words:
$ echo "ad Fawad ad Nazad ad" | sed 's/ ad/ xx /g'
Output: ad Fawad xx Nazad xx
$ echo "ad Fawad ad Nazad ad" | sed 's/ ad / xx /g'
Output: ad Fawad xx Nazad ad
$ echo "ad Fawad ad Nazad ad" | sed 's/ad/ xx /g'
Output: xx Faw xx xx Naz xx xx
$ echo "ad Fawad ad Nazad ad" | sed 's/
Output: ad Fawad ad Nazad ad
$ echo "ad Fawad ad Nazad ad" | sed 's/\
Output: xx Fawad xx Nazad xx
$ echo "ad Fawad ad Nazad ad" | sed 's/\
Output: xx Fawad xx Nazad xx
END of Tutorial 2.
Tuesday, 23 November 2010
PL/SQL Script to Compare All Rows in Two Tables...
DEFINE V_TABLE_1 = 'TABLE_ONE_NAME';
DEFINE V_TABLE_2 = 'TABLE_TWO_NAME';
SET SERVEROUTPUT ON
/
DECLARE
COLUMN_STRING VARCHAR(1000):='''START''';
HASH_TABLE_1 NUMBER;
HASH_TABLE_2 NUMBER;
BEGIN
FOR MINT IN
(
SELECT COLUMN_NAME FROM USER_TAB_COLUMNS where table_name = '&V_TABLE_1'
)
LOOP
COLUMN_STRING := COLUMN_STRING ||'||'|| MINT.COLUMN_NAME;
END LOOP;
SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE(COLUMN_STRING,1,POWER(2,16)-1)) INTO HASH_TABLE_1 FROM &V_TABLE_1;
DBMS_OUTPUT.PUT_LINE('SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE('||COLUMN_STRING||',1,POWER(2,16)-1)) INTO HASH_TABLE_1 FROM &V_TABLE_1');
DBMS_OUTPUT.PUT_LINE('Hash Table 1-1 :'||HASH_TABLE_1);
SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE(COLUMN_STRING,1,POWER(2,16)-1)) INTO HASH_TABLE_2 FROM &V_TABLE_2;
DBMS_OUTPUT.PUT_LINE('SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE('||COLUMN_STRING||',1,POWER(2,16)-1)) INTO HASH_TABLE_2 FROM &V_TABLE_2');
DBMS_OUTPUT.PUT_LINE('Hash Table 2-1 :'||HASH_TABLE_2);
IF HASH_TABLE_1 = HASH_TABLE_2 THEN
DBMS_OUTPUT.PUT_LINE('TABLES MATCH');
ELSE
DBMS_OUTPUT.PUT_LINE('TABLES DO NOT MATCH');
END IF;
SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE(COLUMN_STRING,1,POWER(2,18)-1)) INTO HASH_TABLE_1 FROM &V_TABLE_1;
DBMS_OUTPUT.PUT_LINE('SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE('||COLUMN_STRING||',1,POWER(2,18)-1)) INTO HASH_TABLE_1 FROM &V_TABLE_1');
DBMS_OUTPUT.PUT_LINE('Hash Table 1-2 :'||HASH_TABLE_1);
SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE(COLUMN_STRING,1,POWER(2,18)-1)) INTO HASH_TABLE_2 FROM &V_TABLE_2;
DBMS_OUTPUT.PUT_LINE('SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE('||COLUMN_STRING||',1,POWER(2,18)-1)) INTO HASH_TABLE_2 FROM &V_TABLE_2');
DBMS_OUTPUT.PUT_LINE('Hash Table 2-2 :'||HASH_TABLE_2);
IF HASH_TABLE_1 = HASH_TABLE_2 THEN
DBMS_OUTPUT.PUT_LINE('TABLES MATCH');
ELSE
DBMS_OUTPUT.PUT_LINE('TABLES DO NOT MATCH');
END IF;
SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE(COLUMN_STRING,1,POWER(2,20)-1)) INTO HASH_TABLE_1 FROM &V_TABLE_1;
DBMS_OUTPUT.PUT_LINE('SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE('||COLUMN_STRING||',1,POWER(2,20)-1)) INTO HASH_TABLE_1 FROM &V_TABLE_1');
DBMS_OUTPUT.PUT_LINE('Hash Table 1-3 :'||HASH_TABLE_1);
SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE(COLUMN_STRING,1,POWER(2,20)-1)) INTO HASH_TABLE_2 FROM &V_TABLE_2;
DBMS_OUTPUT.PUT_LINE('SELECT SUM(DBMS_UTILITY.GET_HASH_VALUE('||COLUMN_STRING||',1,POWER(2,20)-1)) INTO HASH_TABLE_2 FROM &V_TABLE_2');
DBMS_OUTPUT.PUT_LINE('Hash Table 2-3 :'||HASH_TABLE_2);
IF HASH_TABLE_1 = HASH_TABLE_2 THEN
DBMS_OUTPUT.PUT_LINE('TABLES MATCH');
ELSE
DBMS_OUTPUT.PUT_LINE('TABLES DO NOT MATCH');
END IF;
END;
/
Oracle: Materialized View
Create a Materialized View:
---------------------------
CREATE MATERIALIZED VIEW "SCHEMA_NAME"."MV_NAME" ("Column_1", "Column_2", "Column_3", "Column_4", "Column_5", "Column_6") ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING TABLESPACE "USERS" BUILD IMMEDIATE USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 REFRESH COMPLETE ON DEMAND START WITH sysdate+0 NEXT sysdate+2/24 USING DEFAULT LOCAL ROLLBACK SEGMENT USING ENFORCED CONSTRAINTS DISABLE QUERY REWRITE
AS
SELECT Column_1 ,
Column_2 ,
Column_3 ,
Column_4 ,
Column_5 ,
Column_6
FROM Table_name
Query Metadata for MV's:
------------------------
SELECT mview_name, refresh_mode, refresh_method,
last_refresh_type, last_refresh_date
FROM user_mviews;
More Information: http://www.dba-oracle.com/t_materialized_view_fast_refresh_performance.htm
SED : Tutorial 1
$echo day | sed s/day/night/
Output: night
$echo Sunday | sed 's/day/night/'
Output: Sunnight
slash/underscore/colon as a delimiter
---------------
$echo "/home/fawad/sed" | sed 's/\/home\/fawad\/sed/\/home\/nazir\/fawad/'
Output: /home/nazir/fawad
$echo "/home/fawad/sed" | sed 's_/home/fawad/sed_/home/nazir/fawad_'
Output: /home/nazir/fawad
$echo "/home/fawad/sed" | sed 's:/home/fawad/sed:/home/nazir/fawad:'
Output: /home/nazir/fawad
Using & as the matched string
-----------------------
$echo "123 Fawad Nazir" | sed 's/F[a-z]*/(&)/'
Output: 123 (Fawad) Nazir
The values is saved in &. So now you can use it in different ways...
$echo "123 Fawad Nazir" | sed 's/F[a-z]*/(&) [&] _&_ *&*/'
Output: 123 (Fawad) [Fawad] _Fawad_ *Fawad* Nazir
Fun: Only Print a and nothing else
$echo "Fawad Nazir Is a Great Man hahahaha" | sed s/[^a]/\ /g
Output: a a a a a a a a a a
Sunday, 21 November 2010
Download Forex Rates Using AWK...
I am writing an application to do Forex Analysis in AWK & SED... using SydneyForex Web-site:
Simple: In order to get the rates for AUD/PKR...
$wget https://www.sydneyforex.com.au/RateHistory.aspx?id=1
$awk '/PAKISTAN/' pakfile.txt | awk '{split($2,a,">")} {split($3,b,"<")} {split($5,c,"<")} {split(c[1],d,">")} {print a[2], b[1]," ", d[2]}';
DONE....
Stay Tuned...
Tuesday, 16 November 2010
Using Mail Server on Linux...
$mailx -s "Email Sibject" User_Name@Host_Name < Message_File_Name
Check new emails:
View all emails:
Goto Home Directoty $cd ~
Then, you should find a mbox folder
$view mbox
Saturday, 13 November 2010
Setting Up a Web-Service Core Engine Based on Axis2…
Main Web Page of Axis2: http://ws.apache.org/axis2/
Now we will follow the installation guide:
http://ws.apache.org/axis2/1_1/installationguide.html
Downloading and installing ANT:
Download Page : http://ant.apache.org/bindownload.cgi
Installation Page : http://ant.apache.org/manual/index.html
Downloading and installing Maven:
http://maven.apache.org/
Download Page : http://maven.apache.org/download.html
Install guide : http://maven.apache.org/maven-1.x/start/install.html
Deploy axis2.war in the tomcat servlet engine.
Login for axis2 admin console:
username: admin
password: axis2
Installing and updating the kernel to Linux-2.6.16 (Ubuntu – IDE)
1. Install Ubuntu 5.10.
2. To setup the root password, reboot the machine and press ESc to go into grub mode.
To to the recovery mode of Linux and press enter.
You will get to # prompt.
Type #passwd root, enter new password and reboot #init 6.
3. Goto System -> Administrator -> Networking and enable the eth0 card for networking support.
4. Goto System ->Administrator -> Synaptic Package Manager
5. Goto Settings -> Repositories. Add Community Maintained (Universe) and press OK.
6. Press “Reload” to update the package list.
7. Goto Terminal: and run all the following commands:
$sudo apt-get update
$sudo apt-get install build-essential
$sudo apt-get install kernel-package
$sudo apt-get install gcc
$sudo apt-get install libncurses5
$sudo apt-get install libncurses5-dev
$sudo apt-get install libqt3-mt-dev
8. Now configure ftp server to transfer new linux 2.6.16 files.
9. I will go for vsftp. You can also configure ftpd, ws-ftpd or proftpd etc.
To install vsftpd:
$sudo apt-get install vsftpd, This will install vsftpd server and start it.
Now we need to make some modifications to the configuration file.
comment #anonymous_enable=YES
Uncomment local_enable=YES
Uncomment write_enable=YES
Save this file and restart vsftpd by running this command. $sudo /etc/init.d/vsftpd restart
10. Upload linux-2.6.16.tar using ftp.
11. copy linux-2.6.16.tar to /usr/src/ folder.
12. cd /usr/src
13. $sudo tar –bzip2 -xvf linux-2.6.12.tar.bz2
14. $sudo ln -s /usr/src/linux-2.6.12 /usr/src/linux
15. Run $sudo make menuconfig or $sudo make xconfig to configure your new kernel.
16. $sudo make-kpkg clean
17. $sudo make-kpkg -initrd –append-to-version=-custom kernel_image modules_image kernel_headers
18. $sudo dpkg -i kernel-image-2.6.16-custom_10.00.Custom_i386.deb
19. $sudo dpkg -i kernel-headers-2.6.16-custom_10.00.Custom_i386.deb
20. Reboot the system $sudo init 6.
Setting up a wireless Testbed…(Host-AP drivers)
S#1: Machine A Master Mode and Machine B Managed Mode.
Machine A:
$sudo iwconfig wlan0 mode Master
$sudo iwconfig wlan0 essid “Hello-1″
Set the Static IP Address: 10.10.5.2 Mask: 255.0.0.0
root@Ubuntu-01:/etc/network# iwconfig wlan0
Warning: Driver for device wlan0 has been compiled with version 19
of Wireless Extension, while this program supports up to version 18.
Some things may be broken…
wlan0 IEEE 802.11b ESSID:”Hello-1″
Mode:Master Access Point: 00:00:00:00:00:00 Bit Rate:11 Mb/s
Sensitivity=1/3
Retry min limit:8 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
root@Ubuntu-01:/etc/network# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:02:6F:34:0B:79
inet addr:10.10.5.2 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::202:6fff:fe34:b79/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:69 errors:0 dropped:1 overruns:0 frame:0
TX packets:63 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4970 (4.8 KiB) TX bytes:5220 (5.0 KiB)
Interrupt:3 Base address:0×3100
Machine B:
$sudo iwconfig wlan0 mode Managed
Set the Static IP Address: 10.10.5.3 Mask: 255.0.0.0
Important : Gateway wlan0
Connect to EssID : Hello-1
fawad@nicta123:~$ iwconfig wlan0
Warning: Driver for device wlan0 has been compiled with version 19
of Wireless Extension, while this program supports up to version 18.
Some things may be broken…
wlan0 IEEE 802.11b ESSID:”Hello-1″
Mode:Managed Frequency:2.422 GHz Access Point: 00:02:6F:34:0B:79
Bit Rate:2 Mb/s Sensitivity=1/3
Retry min limit:8 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=56/70 Signal level=-19 dBm Noise level=-75 dBm
Rx invalid nwid:0 Rx invalid crypt:3 Rx invalid frag:0
Tx excessive retries:30 Invalid misc:12165 Missed beacon:0
fawad@nicta123:~$ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:60:B3:29:92:EE
inet addr:10.10.5.3 Bcast:10.255.255.255 Mask:255.0.0.0
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:8799 errors:0 dropped:0 overruns:0 frame:0
TX packets:12472 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:853532 (833.5 KiB) TX bytes:1505635 (1.4 MiB)
Interrupt:3 Base address:0xe100
Now try pingning from the both ends. I think they should work.
S#2: Both Machine A & B in Ad-Hoc Mode.
Now in this case we have to see that in order for the machines to work in Ad-Hoc mode they should have same essid and channel.
Now lets configure machine A:
$sudo iwconfig wlan0 mode Ad-Hoc
$sudo iwconfig wlan0 channel 3
$sudo iwconfig wlan0 essid “Home”
fawad@Ubuntu-01:~$ iwconfig wlan0
Warning: Driver for device wlan0 has been compiled with version 19
of Wireless Extension, while this program supports up to version 18.
Some things may be broken…
wlan0 IEEE 802.11b ESSID:”Home”
Mode:Ad-Hoc Frequency:2.422 GHz Cell: 02:60:1B:27:92:EE
Bit Rate:11 Mb/s Sensitivity=1/3
Retry min limit:8 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=56/70 Signal level=-40 dBm Noise level=-96 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:22 Invalid misc:40 Missed beacon:0
fawad@Ubuntu-01:~$ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:02:6F:34:0B:79
inet addr:10.10.5.2 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::202:6fff:fe34:b79/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:144 errors:0 dropped:2 overruns:0 frame:0
TX packets:163 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:13304 (12.9 KiB) TX bytes:17560 (17.1 KiB)
Interrupt:3 Base address:0×3100
On Machine B:
$sudo iwconfig wlan0 mode Ad-Hoc
$sudo iwconfig wlan0 channel 3
$sudo iwconfig wlan0 essid “Home”
fawad@nicta123:~$ iwconfig wlan0
Warning: Driver for device wlan0 has been compiled with version 19
of Wireless Extension, while this program supports up to version 18.
Some things may be broken…
wlan0 IEEE 802.11b ESSID:”Home”
Mode:Ad-Hoc Frequency:2.422 GHz Cell: 02:60:1B:27:92:EE
Bit Rate:11 Mb/s Sensitivity=1/3
Retry min limit:8 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=55/70 Signal level=-18 dBm Noise level=-73 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:52 Invalid misc:984 Missed beacon:0
fawad@nicta123:~$ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:60:B3:29:92:EE
inet addr:10.10.5.3 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::260:b3ff:fe29:92ee/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:144 errors:0 dropped:0 overruns:0 frame:0
TX packets:271 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:13300 (12.9 KiB) TX bytes:24228 (23.6 KiB)
Interrupt:3 Base address:0xe100
Now try pinging each of the hosts i guess they should work.
Linux Commands…
Web Page With All Linux Commands…
Command to find what all files are open: $lsof
Command to see what is done when a command is executed: $strace
Command to change the file system of a disk
$sudo mkfs.ext3 -cv -L usbdisk2 /dev/sdc1
dpkg – a medium-level package manager for Debian
————————————————
This is like an rpm for Red-hat linux.
Man Page: http://www.fifi.org/cgi-bin/man2html/usr/share/man/man8/dpkg.8.gz
To list packages related to the editor vi:
dpkg -l ‘*vi*’
To search the listing of packages yourself:
less /var/lib/dpkg/available
To remove an installed elvis package:
dpkg -r elvis
To install a package, you first need to find it in an archive or CDROM. The “available” file shows that the vim package is in section “editors”:
cd /cdrom/hamm/hamm/binary/editors dpkg -i vim_4.5-3.deb
How to load Kernel modules at boot time…
fawad@Ubuntu-01:~$ more /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.
lp
mousedev
psmouse
How to Blacklist a module…
fawad@Ubuntu-01:/etc/hotplug$ echo ‘blacklist orinoco’ | sudo tee -a
/etc/modprobe.d/my_blacklist
blacklist orinoco
fawad@Ubuntu-01:/etc/hotplug$ echo ‘blacklist orinoco_cs’ | sudo tee
-a /etc/modprobe.d/my_blacklist
blacklist orinoco_cs
Where orinoco_cs & orinoco are the modules names.
The above tutorial will blacklist the kernel modules at the starup. But you modules might be loaded which anything is hotplugged into your computer.
For that i could not actually come-up with a solution but i think the way is to intsert modules names in the file:
root@Ubuntu-01:/etc/network# more /etc/hotplug/blacklist
Friday, 12 November 2010
JBoss Remote Debugging... LINUX.
JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
I would recommend not to modify the run.sh file, rather just uncomment
the following line in the run.conf file in the same folder:
# Sample JPDA settings for remote socket debuging
JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
SIMPLE :).
Tuesday, 9 November 2010
Experience While Copying a 42GB file into a Seagate USB Hardrive in Ubuntu Linux…
First of all i will split the file into 10GB pieces. The file name is: enwiki-20070908-stub-meta-history.xml
fawad@crete:~/wiki$ split -b 4000m enwiki-20070908-stub-meta-history.xml
Now i will copy a piece by piece into my seagate external hardrive. I am copying this file from a remote server to my machine
root@fawad-laptop:/home/fawad# scp fawad@crete.ex.nii.ac.jp:/home/fawad/wiki/enwiki-20070908-stub-meta-history.xml /media/usb0/niidata/split/
fawad@crete.ex.nii.ac.jp’s password:
enwiki-20070908-stub-meta-history.xml 10% 4091MB 10.5MB/s 57:03 ETAFile size limit exceeded (core dumped)
This means only files less than 4GB are supported. So i again spilled the files to 4GB file each.
Another important thing to note is that i had to use root login to copy file to my external seagate USB hardrive.
Now once i have splited the files into 4GB chunks. Now use the following command to copy all the files from this folder to one of the folder in the seagate harddrive.
root@fawad-laptop:/home/fawad# scp -r fawad@crete.ex.nii.ac.jp:/home/fawad/wiki/wikidata/ /media/usb0/niidata/wikifawad@crete.ex.nii.ac.jp’s password:
.nfs0000000000d5005100000001 100% 435MB 10.6MB/s 00:41
xad 27% 1101MB 9.5MB/s 05:05 ETARead from remote host crete.ex.nii.ac.jp: Connection reset by peer
xad 100% 4000MB 9.8MB/s 06:49
xag 100% 1233MB 9.8MB/s 02:06
xac 38% 1522MB 10.6MB/s 03:53 ETAh
xac 43% 1734MB 11.1MB/s 03:25 ETA
xac 100% 4000MB 10.1MB/s 06:38
xaf 100% 4000MB 10.2MB/s 06:32
xae 100% 4000MB 10.5MB/s 06:22
xaa 100% 4000MB 9.9MB/s 06:46
xab 39% 1573MB 9.9MB/s 04:05 ETARead from remote host crete.ex.nii.ac.jp: Connection reset by peer
xab 100% 4000MB 9.6MB/s 06:57
Installing MySql on Ubuntu Linux
fawad@fawad-desktop:~$ sudo apt-get install mysql-server
fawad@fawad-desktop:~$ mysqladmin -u root password 123456
fawad@fawad-desktop:~$ mysql -u root -p
mysql> CREATE DATABASE realitymining;
Query OK, 1 row affected (0.00 sec)
Upgrade Ubuntu from Edgy to Feisty
http://www.ubuntugeek.com/upgrade-ubuntu-610-edgy-eft-to-ubuntu-704-feisty-fawn-2.html
Method 2 – Using apt-get
Edit your /etc/apt/sources.list as root. Change every occurrence of edgy to feisty.
Use any prefered editor. If you have a CD-ROM line in your file, then remove it.
sudo vi /etc/apt/sources.list
or
use the following Simple command
sudo sed -e ’s/\edgy/ feisty/g’ -i /etc/apt/sources.list
Now you need to update the source list using the following command
sudo apt-get update
Upgrade using the following command
sudo apt-get dist-upgrade
Double check your process was finished properly using the following commd
sudo apt-get -f install
sudo dpkg –configure -a
Now you need to Reboot your machine to take your new ubuntu 7.04 installation to effect all changes.
Testing Your Upgrade
You can check the ubuntu version installed using the following command
sudo lsb_release -a
Output Looks like below
Distributor ID: Ubuntu
Description: Ubuntu feisty (development branch)
Release: 7.04
Codename: feisty
or
Just type the following command in your terminal
cat /etc/issue
Output Lokks like below
Ubuntu feisty (development branch) \n \l
Graph Visualization File Format...
Few visualization formats.
1. dot
2. fdp
3. neato
4. graphml
5. gml
6. ygf
Friday, 5 November 2010
Limiting the rows being displayed in Oracle...
ROWNUM in SQL | ||
| rownum is a pseudo column. It numbers the records in a result set. The first record that meets the where criteria in a select statement is given rownum=1, and every subsequent record meeting that same criteria increases rownum. After issuing a select statement, one of the last steps that oracle does is to assign an increasing (starting with 1, increased by 1) number to each row returned. The value of this row number can always be queried with rownum in a select statement: select It is important to realize that the first row's rownum is always 1. This implies that the following query won't return a single row: select This is so because the first row would have to meet the following two mutually excluding criterias:
In order to do this query in the (probably) intended spirit, a sub-query must be executed: select |
Substituting NULL in Oracle using NVL...
Oracle/PLSQL: NVL Function
In Oracle/PLSQL, the NVL function lets you substitute a value when a null value is encountered.
The syntax for the NVL function is:
NVL( string1, replace_with )
string1 is the string to test for a null value.
replace_with is the value returned if string1 is null.
Applies To:
- Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g
Example #1:
select NVL(supplier_city, 'n/a')
from suppliers;
The SQL statement above would return 'n/a' if the supplier_city field contained a null value. Otherwise, it would return the supplier_city value.
Example #2:
select supplier_id,
NVL(supplier_desc, supplier_name)
from suppliers;
This SQL statement would return the supplier_name field if the supplier_desc contained a null value. Otherwise, it would return the supplier_desc.
Example #3:
select NVL(commission, 0)
from sales;
This SQL statement would return 0 if the commission field contained a null value. Otherwise, it would return the commission field.
Frequently Asked Questions
Question: I tried to use the NVL function through VB to access Oracle DB.
To be precise,
select NVL(DIstinct (emp_name),'AAA'),................ from.................
I got an oracle error when I use distinct clause with NVL, but when I remove distinct it works fine.
Answer: It is possible to the use the DISTINCT clause with the NVL function. However, the DISTINCT must come before the use of the NVL function. For example:
select distinct NVL(emp_name, 'AAA')
from employees;
Hope this helps!
Question: Is it possible to use the NVL function with more than one column with the same function call? To be clear, if i need to apply this NVL function to more than one column like this:
NVL(column1;column2 ...... , here is the default value for all )
Answer: You will need to make separate NVL function calls for each column. For example:
select NVL(table_name, 'not found'), NVL(owner, 'not found')
from all_tables;
Monday, 1 November 2010
Oracle/PLSQL: Lag Function
In Oracle/PLSQL, the lag function is an analytic function that lets you query more than one row in a table at a time without having to join the table to itself. It returns values from a previous row in the table. To return a value from the next row, try using the lead function.
The syntax for the lag function is:
lag ( expression [, offset [, default] ] )
over ( [ query_partition_clause ] order_by_clause )
expression is an expression that can contain other built-in functions, but can not contain any analytic functions.
offset is optional. It is the physical offset from the current row in the table. If this parameter is omitted, the default is 1.
default is optional. It is the value that is returned if the offset goes out of the bounds of the table. If this parameter is omitted, the default is null.
Applies To:
- Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g
For example:
Let's take a look at an example. If we had an orders table that contained the following data:
ORDER_DATE PRODUCT_ID QTY 25/09/2007 1000 20 26/09/2007 2000 15 27/09/2007 1000 8 28/09/2007 2000 12 29/09/2007 2000 2 30/09/2007 1000 4
And we ran the following SQL statement:
select product_id, order_date,
lag (order_date,1) over (ORDER BY order_date) AS prev_order_date
from orders;
It would return the following result:
PRODUCT_ID ORDER_DATE PREV_ORDER_DATE 1000 25/09/2007 2000 26/09/2007 25/09/2007 1000 27/09/2007 26/09/2007 2000 28/09/2007 27/09/2007 2000 29/09/2007 28/09/2007 1000 30/09/2007 29/09/2007
Since we used an offset of 1, the query returns the previous order_date.
If we had used an offset of 2 instead, it would have returned the order_date from 2 orders before. If we had used an offset of 3, it would have returned the order_date from 3 orders before....and so on.
If we wanted only the orders for a given product_id, we could run the following SQL statement:
select product_id, order_date,
lag (order_date,1) over (ORDER BY order_date) AS prev_order_date
from orders
where product_id = 2000;
It would return the following result:
PRODUCT_ID ORDER_DATE PREV_ORDER_DATE 2000 26/09/2007 2000 28/09/2007 26/09/2007 2000 29/09/2007 28/09/2007
In this example, it returned the previous order_date for product_id = 2000 and ignored all other orders.
Monday, 25 October 2010
Oracle MetaData...
SELECT
TABLE_NAME,
COLUMN_NAME
FROM
ALL_TAB_COLUMNS
where
COLUMN_NAME like '%COLUMN_NAME%';
More about it on : http://en.wikipedia.org/wiki/Oracle_metadata
Wednesday, 13 October 2010
Latex on Ubuntu....
Link: http://linuxandfriends.com/2009/10/06/install-latex-in-ubuntu-linux/
This guide explains how to install LaTeX in Ubuntu Linux. LaTeX is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents but it can be used for almost any form of publishing.
LaTeX is not a word processor! Instead, LaTeX encourages authors not to worry too much about the appearance of their documents but to concentrate on getting the right content.
How to install LaTeX in Ubuntu
In Ubuntu Linux, you have to first install LaTeX to use it. This is how LaTeX is installed in Ubuntu.
$ sudo apt-get install texlive
The above command will install a basic subset of TeX Live’s functionality. To install all the packages in the LaTeX distribution, you have to run the following command.
$ sudo apt-get install texlive-full
Gedit LaTeX Plugin
Gedit has a plugin for LaTeX which converts Gedit into a LaTeX editor. You can install the Gedit LaTeX plugin as follows :
$ sudo apt-get install gedit-latex-plugin
Once you install the plug-in, you will have to enable the plug-in in Gedit to begin using it. This is achieved by opening Gedit Preferences (GEdit > Edit > Preferences
). Then clicking on the Plugins tab and turning on the “Gedit LaTeX plugin”. Now when ever you open a TeX file, you will have access to the LaTeX menu in Gedit.
Recommended LaTeX Packages
latex-beamer
– Beamer package is used to create presentations. It is an excellent LaTeX class that supports dynamic effects.TeXPower
– Is a bundle of style and class files for creating dynamic online presentations with LaTeX.Prosper
– A LaTeX class for writing transparencies.texlive-pictures
– This is a LaTeX package for drawing graphics. It contain several classes such as ‘curve’ (for creating resumes), ‘bardiag’ (for bar graphs), ‘pmgraph’ (poor man’s graphics) and so on.texlive-latex-extra
– This is a large collection of addon packages for LaTeX. The full list of classes in this package are listed here.
This is the full command I used to install LaTeX on my machine running Ubuntu Linux.
$ sudo apt-get install gedit-latex-plugin texlive-fonts-recommended latex-beamer texpower texlive-pictures texlive-latex-extra texpower-examples imagemagick
Tuesday, 12 October 2010
Dealing with LOB in Oracle
Link: http://www.java2s.com/Tutorial/Oracle/0660__Large-Objects/Updateclobdata.htm
SQL>
SQL> CREATE TABLE myClobTable (id NUMBER,clob_data CLOB);
Table created.
SQL>
SQL> CREATE TABLE myLongTable (id NUMBER,long_data LONG);
Table created.
SQL>
SQL> INSERT INTO myLongTable VALUES (100,RPAD('A',200000,'A'));
1 row created.
SQL>
SQL>
SQL> update myClobTable set clob_data =(select to_lob(long_data)from
2 myLongTable where id =100)
3
SQL> drop table myLongTable;
Table dropped.
SQL>
SQL>
SQL> drop table myClobTable;
Table dropped.
Friday, 8 October 2010
Apache JMeter...
http://jakarta.apache.org/jmeter/index.html
Java Performance Tuning Using Hprof...
Link : http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.50/diag/tools/hprof.html
Using the HPROF ProfilerHPROF is a demonstration profiler shipped with the IBM® SDK that uses the JVMTI to collect and record information about Java execution. Use it to work out which parts of a program are using the most memory or processor time.
java -Xrunhprof[:
When you run Java with HPROF, a file is created when the program ends. This file is placed in the current working directory and is called java.hprof.txt (java.hprof if binary format is used) unless a different file name has been given. This file contains a number of different sections, but the exact format and content depend on the selected options.
If you need more information about HPROF than is contained in this section, see http://java.sun.com/developer/technicalArticles/Programming/HPROF.html.
The command java -Xrunhprof:help shows the options available:
- heap=dump|sites|all
- This option helps in the analysis of memory usage. It tells HPROF to generate stack traces, from which you can see where memory was allocated. If you use the heap=dump option, you get a dump of all live objects in the heap. With heap=sites, you get a sorted list of sites with the most heavily allocated objects at the top. The default value all gives both types of output.
- cpu=samples|times|old
- The cpu option provides information that is useful in determining where the processor spends most of its time. If cpu is set to samples, the JVM pauses execution and identifies which method call is active. If the sampling rate is high enough, you get a good picture of where your program spends most of its time. If cpu is set to time, you receive precise measurements of how many times each method was called and how long each execution took. Although this option is more accurate, it slows down the program. If cpu is set to old, the profiling data is produced in the old HPROF format.
- interval=y|n
- The interval option applies only to cpu=samples and controls the time that the sampling thread sleeps between samples of the thread stacks.
- monitor=y|n
- The monitor option can help you understand how synchronization affects the performance of your application. Monitors implement thread synchronization. Getting information about monitors can tell you how much time different threads are spending when trying to access resources that are already locked. HPROF also gives you a snapshot of the monitors in use. This information is useful for detecting deadlocks.
- format=a|b
- The default for the output file is ASCII format. Set format to 'b' if you want to specify a binary format, which is required for some utilities like the Heap Analysis Tool.
- file=
- Use the file option to change the name of the output file. The default name for an ASCII file is java.hprof.txt. The default name for a binary file is java.hprof.
- force=y|n
- Typically, the default (force=y) overwrites any existing information in the output file. So, if you have multiple JVMs running with HPROF enabled, use force=n, which appends additional characters to the output file name as needed.
- net=
: - To send the output over the network rather than to a local file, use the net option.
- depth=
- The depth option indicates the number of method frames to display in a stack trace. The default is 4.
- thread=y|n
- If you set the thread option to y, the thread id is printed beside each trace. This option is useful if you cannot see which thread is associated with which trace. This type of problem might occur in a multi-threaded application.
- doe=y|n
- The default behavior is to collect profile information when an application exits. To collect the profiling data during execution, set doe (dump on exit) to n.
- msa=y|n
- The msa option applies only to Solaris and causes the Solaris Micro State Accounting to be used. This feature is unsupported on IBM SDK platforms.
- cutoff=
- Many sample entries are produced for a small percentage of the total execution time. By default, HPROF includes all execution paths that represent at least 0.0001 percent of the time spent by the processor. You can increase or decrease that cutoff point using this option. For example, to eliminate all entries that represent less than one-fourth of one percent of the total execution time, you specify cutoff=0.0025.
- verbose=y|n
- This option generates a message when dumps are taken. The default is y.
- lineno=y|n
- Each frame typically includes the line number that was processed, but you can use this option to suppress the line numbers from the output listing. If enabled, each frame contains the text Unknown line instead of the line number.
TRACE 1056: java/util/Locale.toUpperCase(Locale.java:Unknown line) java/util/Locale.
(Locale.java:Unknown line) java/util/Locale. (Locale.java:Unknown line) sun/io/CharacterEncoding.aliasName(CharacterEncoding.java:Unknown line)
- Explanation of the HPROF output file
The top of the file contains general header information such as an explanation of the options, copyright, and disclaimers. A summary of each thread follows.
Thursday, 7 October 2010
Iterating over collection variables [PL/SQL]
Nested tables
declare type table_varchar is table of varchar2(10); var_table_varchar table_varchar; begin var_table_varchar := table_varchar('one', 'two', 'three', 'four'); for elem in 1 .. var_table_varchar.count loop dbms_output.put_line(elem || ': ' || var_table_varchar(elem)); end loop; end; /
1: one 2: two 3: three 4: four
Index by tables
declare type assoc_varchar is table of varchar2(10) index by pls_integer; var_assoc_varchar assoc_varchar; elem varchar2(10); begin var_assoc_varchar(40) := 'forty'; var_assoc_varchar(10) := 'ten'; var_assoc_varchar(30) := 'thirty'; var_assoc_varchar(20) := 'twenty'; elem := var_assoc_varchar.first; while elem is not null loop dbms_output.put_line(elem || ': ' || var_assoc_varchar(elem)); elem := var_assoc_varchar.next(elem); end loop; end; /
10: ten 20: twenty 30: thirty 40: forty
varrays
declare type varray_varchar is varying array(20) of varchar2(10); var_varray_varchar varray_varchar; begin var_varray_varchar := varray_varchar('un', 'deux', 'trois', 'quattre'); for elem in 1 .. var_varray_varchar.count loop dbms_output.put_line(elem || ': ' || var_varray_varchar(elem)); end loop; end; /
1: un 2: deux 3: trois 4: quattre
Wednesday, 6 October 2010
WITH Clause Oracle
SELECT
More in with : http://psoug.org/reference/with.html
SQL Function Reference: Oracle vs. SQL Server
*same for both databases
Math Functions | ||
---|---|---|
Function | Oracle | SQL Server |
Absolute value | ABS | ABS |
Arc cosine | ACOS | ACOS |
Arc sine | ASIN | ASIN |
Arc tangent of n | ATAN | ATAN |
Arc tangent of n and m | ATAN2 | ATN2 |
Smallest integer >= value | CEIL | CEILING |
Cosine | COS | COS |
Hyperbolic cosine | COSH | COT |
Exponential value | EXP | EXP |
Round down to nearest integer | FLOOR | FLOOR |
Natural logarithm | LN | LOG |
Logarithm, any base | LOG(N) | N/A |
Logarithm, base 10 | LOG(10) | LOG10 |
Modulus (remainder) | MOD | USE MODULO (%) OPERATOR |
Power | POWER | POWER |
Random number | N/A | RAND |
Round | ROUND | ROUND |
Sign of number | SIGN | SIGN |
Sine | SIN | SIN |
Hyperbolic sine | SINH | N/A |
Square root | SQRT | SQRT |
Tangent | TAN | TAN |
Hyperbolic tangent | TANH | N/A |
Truncate | TRUNC | N/A |
Highest number in list | GREATEST | N/A |
Lowest number in list | LEAST | N/A |
Convert number if NULL | NVL | ISNULL |
Standard deviation | STDDEV | STDEV |
Variance | VARIANCE | VAR |
String Functions | ||
---|---|---|
Function | Oracle | SQL Server |
Convert character to ASCII | ASCII | ASCII |
String concatenate | CONCAT | (expression + expression) |
Convert ASCII to character | CHR | CHAR |
Return starting point of character in character string (from left) | INSTR | CHARINDEX |
Convert characters to lowercase | LOWER | LOWER |
Convert characters to uppercase | UPPER | UPPER |
Pad left side of character string | LPAD | N/A |
Remove leading blank spaces | LTRIM | LTRIM |
Remove trailing blank spaces | RTRIM | RTRIM |
Starting point of pattern in character string | INSTR | PATINDEX |
Repeat character string multiple times | RPAD | REPLICATE |
Phonetic representation of character string | SOUNDEX | SOUNDEX |
String of repeated spaces | RPAD | SPACE |
Character data converted from numeric data | TO_CHAR | STR |
Substring | SUBSTR | SUBSTRING |
Replace characters | REPLACE | STUFF |
Capitalize first letter of each word in string | INITCAP | N/A |
Translate character string | TRANSLATE | N/A |
Length of character string | LENGTH | DATALENGTH or LEN |
Greatest character string in list | GREATEST | N/A |
Least character string in list | LEAST | N/A |
Convert string if NULL | NVL | ISNULL |
Date Functions | ||
---|---|---|
Function | Oracle | SQL Server |
Date addition | (use +) | DATEADD |
Date subtraction | (use -) | DATEDIFF |
Last day of month | LAST_DAY | N/A |
Time zone conversion | NEW_TIME | N/A |
First weekday after date | NEXT_DAY | N/A |
Convert date to string | TO_CHAR | DATENAME |
Convert date to number | TO_NUMBER(TO_CHAR()) | DATEPART |
Convert string to date | TO_DATE | CAST |
Get current date and time | SYSDATE | GETDATE() |
Tuesday, 5 October 2010
dumprep.exe 100% CPU...
dumprep.exe is (or should be) a legitimate Microsoft program, one that runs when a program has a critical error and cannot be restored.
Process File: dumprep or dumprep.exe
Process Name: Dump Reporting Tool
Description: Microsoft provided Windows Error Dump Reporting Tool that creates memory dump reports that you can send back to Microsoft for further analysis.
The tool is found on Windows XP/2003.
*****************
To fix this problem simply turn off your systems "error reporting".
First check with Task Manager if dumprep.exe is running - if it is stop the process.
Then:
Start > Control Panel > System > Advanced > Error Reporting > select "Disable error reporting"
Problem solvered :)
REF: http://forums.whirlpool.net.au/archive/596370
Wednesday, 29 September 2010
Hello World Oracle Procedure.
CREATE OR REPLACE PROCEDURE skeleton (my_name IN varchar, last_name IN varchar )
IS
BEGIN
DBMS_OUTPUT.PUT_LINE(last_name ||' ' || my_name);
END;
Calling a Precedure.
SET SERVEROUTPUT ON
/
EXECUTE SKELETON('Fawad', 'Nazir')
/
Checking For Table Dependencies in Oracle.
SELECT *
FROM ALL_TAB_COLUMNS
WHERE COLUMN_NAME IN ('XXXXX','YYYYYY')
AND OWNER = 'DB1'
;
Tuesday, 28 September 2010
Getting the Current Schema Name in Oracle...
INTO V_OWNER
FROM DUAL;
Friday, 24 September 2010
Do we have Double in Oracle?
number(p,s)
Where p is the precision and s is the scale.
For example, number(7,2) is a number that has 5 digits before the decimal and 2 digits after the decimal.
alter table
_TABLE_NAME_
modify
(
VAR_LIMIT NUMBER(38,127),
EAR_LIMIT NUMBER(38,127)
);
ERD and UML for Eclipse...
http://amateras.sourceforge.jp/cgi-bin/fswiki_en/wiki.cgi?page=EclipseHTMLEditor
Amateras provides both UML (AmaterasUML) and ERD (AmaterasERD).
Both require installing GEF First.
Installing GEF: https://publib.boulder.ibm.com/infocenter/cchelp/v7r1m0/index.jsp?topic=/com.ibm.rational.clearcase.cc_ms_install.doc/topics/t_install_gef.htm
Installing Graphical Editing Framework (GEF)
Rational ClearCase Remote Client for Eclipse requires that GEF be installed in your Eclipse environment. If you do not have GEF, you must install it before installing the Rational ClearCase Remote Client for Eclipse.
Before you begin
About this task
If your environment already has GEF installed, you do not need to perform this task. To check if it is installed, start Eclipse and click Help > About Eclipse, then click the Feature Details button. If there is an entry with "Graphical Editing Framework" in the Feature Name field and "org.eclipse.gef" in the Feature ID field, then you have GEF installed in your Eclipse environment.
Note: You must be logged in as a local Administrator with sufficient privileges for updating your installation of Eclipse or the IBM Rational Software Delivery Platform.
Download the GEF Runtime feature that corresponds to your version of Eclipse from the Eclipse Web site (http://www.eclipse.org) and unzip it into your Eclipse directory, or follow these steps to install GEF with the Eclipse Update Manager:
Procedure
- Installing GEF with Eclipse 3.2.x and 3.3.x
- On the Eclipse main menu, click Help > Software Updates > Find and Install.
- On the Feature Updates page, select Search for new features to install and then click Next
- On the Update sites to visit page, select Callisto Discovery Site (for Eclipse 3.2) or Europa Discovery Site (for Eclipse 3.3) and expand the option to see a list of available features.
- Select Graphical Editing Framework from the Graphical Editors and Frameworks section of the Callisto Discovery Site for Eclipse 3.2 or Graphical Editing Framework from the Graphical Editors and Frameworks section of the Europa Discovery Site for Eclipse 3.3 and then click Next. (Note that you should choose a version of GEF that corresponds with the version of Eclipse that you are using.)
- On the Search Results page, select Graphical Editing Framework and then click Next.
- On the Feature License page, select I accept the terms in the license agreement... and then click Next. If you do not accept the terms, select Cancel to end the installation.
- On the Install Location page, select the Eclipse sites where you want to install the feature and then click Finish.
- Installing GEF with Eclipse 3.4
- On the Eclipse main menu, click Help > Software Updates.
- On the Available Software page, select Ganymede Update Site and expand the option to see a list of available features.
- Expand the Graphical Editors and Frameworks section and select the Graphical Editing Framework version that corresponds with the version of Eclipse that you are using.
- Click Install.
- On the Install page, click Next.
- On the Review Licenses page, read the license agreement carefully. If you accept the terms, select I accept the terms in the license agreement... and then click Finish. If you do not accept the terms, select Cancel to end the installation.
- When the installation completes, you are prompted to restart Eclipse or apply changes. Click Yes to restart Eclipse.
- Installing GEF with Eclipse 3.5
- On the Eclipse main menu, click Help > Install New Software.
- On the Available Software page, select Galileo - http://download.eclipse.org/releases/galileo from the Work with pull down menu, expand the Modeling option, select the Graphical Modeling Framework SDK option, and click Next.
- On the Install Details page, verify that Graphical Modeling Framework SDK appears as an item to be installed and click Next.
- On the Review Licenses page, read the license agreement carefully. If you accept the terms, select I accept the terms in the license agreements and then click Finish. If you do not accept the terms, select Cancel to end the installation.
- When the installation completes, you are prompted to restart Eclipse or apply changes. Click Yes to restart Eclipse.
Once this is done. Now its easy to install both UML (AmaterasUML) and ERD (AmaterasERD).
For AmaterasUML, just get the latest jars and put in ECLIPSE_HOME/plugins.
For AmaterasERD, the latest jar which is net.java.amateras.db_1.0.7.1.jar does not work for me, so I tried net.java.amateras.db_1.0.6.jar and it worked very well.
BTW, I have eclipse latest version which is 3.5 and the above jar also worked for Eclipse version 3.3.
Azure OpenAI Architecture Patterns & Deployment Patterns
Sharing some useful links that will help customers architect Azure OpenAI solution using the best practices: (1) Azure OpenAI Landing Zone r...
-
Setting up a MPI cluster on Ubuntu involves the following steps: 1. Install OpenMPI on all machines. $sudo apt-get install libopenmpi-de...
-
Very Useful Link: http://people.cc.ku.edu/~grobe/intro-to-LSL/index.html#particle Using the Linden Script Language This page is a short...
-
float p_size = 0.1; default { state_entry() { llSay(0, "Hello, Avatar!"); llSetPrimitiveParams( [ PRIM_...