Posts

Showing posts from 2010

Oracle: OUTER JOIN operator

Just to note that (+) means an OUTER JOIN. Example : select a2 from table_a,table_b where table_a.a1=table_b.b1 (+) and table_b.b1=999999

Mac OS X: how to list all open ports running in your machine

In Mac OS X, I do use netstat -a -p tcp  Though the ideal one to list all open ports in Mac OS X being opened is lsof -i -P | grep -i "listen" Simple command, but hope that helps.

Issue Single Command To Kill a Process In Linux/Unix system

I am so tired of issuing back and forth this 'ps axu' command thing. I was debugging stuff in JBoss and I do always 'ps axu|grep jboss' then I took the process id and kill it by: kill -9 processid Then I just tried killing two process id at a time like for example: kill -9 processid1 processid2 and that will actually kill two process id, however, that's still tedious but it does help in some way. So I figure it out that I can use awk tool for this and get the column where the processid would be printed. So I found out a way with just one command to kill a process either in Linux/Unix system. I did this in my Mac OS X Snow Leopard. kill -9 $(ps -e|grep jboss|awk '{ print $1 }') // works in Snow Leopard or kill -9 $(ps -re|grep sl1 | awk -F ':' '{ print $3}'| awk '{print $1}') // Works in Mac OS X 10.8 Snow Lion or kill -9 $(ps axu|grep jboss|awk '{ print $2 }') // Linux   the '$1' there is the ...

SVN: How-to view modified files being commited to central repository

In order to view base on the revision number, just use the 'svnlook' tool to achieve this. Say for example: svnlook changed -r 23 /opt/repo Where /opt/repo is the central repository. svnlook will look for the 'REPO_PATH/format' file, so just check if that file exist so that you can assure it that it is the right path for your repository. Hope this helps.

Quickest way to create a table in Oracle

I found this very easy and quick to create a table, though sort of copy a table to another table. The syntax is: create table table_to_create as select * from source_table where 1=0 Hope you find this a little bit of help.

Use Shell Editor for Eclipse for editing bash, ksh, csh in Unix/Linux system

Image
I found ShellEd when googling for any shell editor. It was trouble at first because there's no  how-to that directs me, where I expect to have a direct link that I can copy-en-paste to my Eclipse for installation. So what I did, I download ShellEd (as of this writing file version ShellEd-Update-2.0.0_M3.zip) from sourceforge.net and install, as required, the Linux Tools . After installing Linux Tools, I then locate thru archive the ShellEd zip file and install it successfully. It works good and I feel satisfied with this cool tool to be embedded in eclipse. The sample attached shell script is from JBoss twiddle. It does supports syntax highlighting, intellisense which is cool. Hope this helps.

Discrimanator annotation in Hibernate

Just a note I don't want to forget, @Discriminator annotation for Hibernate, is that, it's idea is base on the enum type in database or perhaps just a type discriminator for a record on how to identify it. It's powerful, and is a helpful feature of hibernate.

Test Web Services thru Telnet

I use Mac OS X here, so other OS's might vary but I think in Linux, it is still ppp0 (but not sure with that) for VPN connection interface. 1. First, I use Wireshark in order to capture the packets. 2. Afterwards, I use the ppp0 interface (Mac OS X) then start 3. Now connect thru telnet by example: telnet 192.168.10.51 8080 4. Then paste the example POST POST /api/soap/v2/loyaltyaccount HTTP/1.0 Host: 192.168.10.232:8080 User-Agent: NuSOAP/0.7.3 (1.114) Content-Type: text/xml; charset=ISO-8859-1 SOAPAction: "" Content-Length: 1189 <s:Envelope xmlns:s=' http://schemas. xmlsoap.org/soap/envelope/ '>    <s:Header>       <wsse:Security s:mustUnderstand='1' xmlns:wsse=' http://docs.oasis- open.org/wss/2004/01/oasis- 200401-wss-wssecurity-secext- 1.0.xsd '>         <wsu:Timestamp xmlns:wsu=' http://docs.oasis- open.org/wss/2004/01/oasis- 200401-wss-wssecurity-utility- 1.0.xsd '>        ...

ORA-20000: ORU-10027: buffer overflow, limit of 2000 bytes

The solutions for that error is to specify thru DBMS_OUTPUT.ENABLE(10000). Note that the default value is 2000 characters, and maximum is 1, 000, 000.

Oracle - Get the last inserted id how-to

Just simple, declare a variable with that type, mostly number, then   use the 'returning' syntax   for that. set serveroutput on declare  nr_id number; begin  insert into employees( id, name, age )  values( seq_employees.NEXTVAL, 'Jones', 33 )  returning id into nr_id;  dbms_output.put_line( 'nr_id = ' || nr_id ); end; / Hope this helps.  - Toytoy Gogie

Oracle - Create auto-increment equivalent in MySQL

So for example, I have my table below to create CREATE TABLE "PC2"."TMP_PRODUCT" (   "ID"              NUMBER(38,0) NOT NULL ENABLE,   "ACCOUNTCODE"     VARCHAR2(20 BYTE),   "PRICESEGMENT"    VARCHAR2(20 BYTE),   "BRAND"           VARCHAR2(20 BYTE),   "PRODUCTLENGTH"   NUMBER,   "SALESID"  NUMBER(38,0),   CONSTRAINT "PK_TMP2_WPP_1009_ID" PRIMARY KEY ("ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255,   CONSTRAINT "FK_TMP2_WPP_1009_SID" FOREIGN KEY ("SALESID") REFERENCES "PC2"."SALES" ("ID") DEFERRABLE INITIALLY DEFERRED ENABLE ); Then create a sequence which would manage the incremental part of the index key. CREATE SEQUENCE SEQ_TMP_PRODUCT   START WITH 1 INCREMENT BY 1; Afterwards, create a trigger which what will do is to insert the incremented key of the table. CREATE OR REPLACE TR...

Tunneling Oracle For Port 1521 From Other Server

This set up is that, I cannot open the 1521 if I do directly from the outside host to my SQLDeveloper, so what I did, I tunnel to port 1521 by opening port 1525 to forward it to 1521 to that host I wanted to logged in. Basically, I can login to that system with my ssh account. So the command I did was: ssh -L 1525:localhost:1521 username@your-host.com Where 1525 is your local port to open and 1521 is the port you're going to tunnel, which is the default port for Oracle. For some ways, you can also port forwarding like to port 80, port 110, or IRC ports like 6667-6669. Hope this helps.

Oracle DB - Get the constraints information from a table

I'm beginning now to use Oracle fro development, now expect that I'll be having more SELECT table_name, column_name, CONSTRAINT_NAME FROM all_cons_columns WHERE owner='username_owner' AND constraint_name='UK_CONSTRAINTNAME' ORDER BY position; where UK_CONSTRAINTNAME is a constraintname that you named like UK_USERSPROFILE or UK_USERSPROFILE_FIRSTNAME.

Uncaught exception: this class is not key value coding-compliant for the key window

Image
I'm thinking of this error might be a helpful hint for anybody on iPhone dev. I was encountering this error stuff I have, which you can see on the image down below, My fix for this was under my .xib file. I just open my .xib file and check that my app delegate object has the right class, right window property, and right view controller property. Take a look at below to see how it looks like, Hope this helps.

Creating PVR file using texturetool for iPhone dev

To create a 2 bits per pixel of PVR file as a mipmap, then issue this command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --bits-per-pixel-2 -f PVR -o Brick_2.pvr test.png To create a 4 bit, just use  --bits-per-pixel-4 instead of --bits-per-pixel-2. Brick_2.pvr is the output of the file, then test.png is your file that is height and width of your image file are equivalent in numbers of pixels.  If not a mipmap file, then just remove the -m like, /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --bits-per-pixel-2 -f PVR -o Brick_2.pvr test.png  Hope this helps.

Incompatibility of iconv for PHP 5.2.13 under Mac OS X

Image
I'm confused with this when I compiled 5.2.13 of PHP under Mac OS X Snow Leopard . I did update by downloading and compiling a new version of iconv at http://www.gnu.org/software/libiconv/ and compile it by running ./configure --prefix=/usr/local When I compile PHP with the following "configure" params as CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure  --prefix=/opt/local --mandir=/usr/share/man --infodir=/usr/share/info --with-config-file-path=/etc/ --enable-bcmath --enable-ctype --enable-dom --enable-fileinfo --enable-filter --enable-hash --enable-json --enable-libxml --enable-pdo --enable-phar --enable-session --enable-simplexml --enable-tokenizer --enable-xml --enable-xmlreader --enable-xmlwriter --with-bz2=/opt/local --with-mhash=/opt/local --with-pcre-regex=/opt/local --with-readline=/opt/local --with...

pdftotext not found in CentOS

pdftotext is a tool in Linux that would extract any text readable, which was formatted prior from PDF. When you arrive on not able to find this helpful tools from Linux of your favorite distro, you can find it in the net for  poppler utils  which comprises the pdftotext binary file. It's codebase is base on XPdf 3.0. For CentOS, do yum install poppler* which would install the developer package, poppler package, and the util package of poppler. Hope this helps ;-).

Postfix + Cyrus IMAP Relay access denied (state 14)

Solving this problem was freaking easy. I just did add the user, must have the proper domain name link to your IMAP, like us, I have toytoy.is-a-geek.org. So what I did, I just add first the user's e-mail address like for example: echo "mypassword" | /usr/sbin/saslpasswd2 -p -u toytoy.homeunix.org toytoy@toytoy.homeunix.org  Since I have the script to create an IMAP account for Cyrus, I just run /path/to/imapcreate.pl -u cyrus -m "toytoy@toytoy.is-a-geek.org" -p cyruspassword -s localhost then cd to the assigned virtual_alias file, if your postfix configuration doesn't modify or customized the default config, so execute (mostly /etc/postfix/virtual_alias) cd /etc/postfix/virtual_alias echo "toytoy@toytoy.is-a-geek.org toytoy@toytoy.is-a-geek.org" >> virtual_alias which postmap virtual_alias Then try sending e-mails, you can check the spool at /var/spool/imap/domain/t/toytoy. is-a-geek .org/t/user/toytoy/2. where " 2. " is t...

My guide on how did I able to use autoconf

In my experience, it seems that autoconf  needs Makefile.am and configure.ac. How did I do it, I run autoreconf -i -v -f Makefile.am then I did run automake to create Makefile.in then afterwards, I was able to run ./configure successfully.

Scons Add Prefix Before Install

For my knowledge and guide, sudo scons prefix=/home/hachico/local -j 4 sdl=1 install then this will put the libraries, docs, and bin accordingly into that drectory.

Some CentOS/RHEL/Fedora rpm repositories for yum that would be helpful

I got the repository from remi for my CentOS. By issuing the following commands: su - cd /etc/yum.repos.d wget http://rpms.famillecollet.com/remi-enterprise.repo  For webtatic, rpm –import http://repo.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy wget -P /etc/yum.repos.d/ http://repo.webtatic.com/yum/webtatic.repo  where I got my latest versions of PHP. For EPEL and remi, wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm Some warned to discourage using the RPMForge because of some conflict with the repository under EPEL. EPEL is known for the repository project for Fedora. For RPMForge, rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm This repos might help you fixing problems on looking for available repository packages.   This repositories are well applied for RHEL ...

tesseract compile with libtiff

Image
I just stumbled upon with this tesseract where I wasn't able to figure out what's the problem with libtiff since my libtiff, during configure, always says disabled, so I did able to fix it thru ./configure --prefix=/usr --with-libtiff=/usr/lib I tried to let --with-libtiff only, not giving the specific path, but it fails. So specifying the right path, makes the problem fixed. The current version of 2.04 of tesseract, is what I am compiling for this stuff. My libtiff is, indeed, updated using the current version from http://www.remotesensing.org/libtiff. Remember to have the required librarires installed, and these are libpng-dev libjpeg-dev libtiff-dev zlibg-dev leptonica which all of them are separate libraries that you need to install. Leptonica does image analysis and image processing, which is really cool. tesseract use this as it helps them to OCR images. Hope this helps!

Awk and Bash: Print Linux/Unix User Accounts

There are ways how to do this: awk -F':' '{ print $1 "\t"  $3 }' /etc/passwd That would  print the username and the UID. You can also add the sort command at the end like awk -F':' '{ print $1 "\t"  $3 }' /etc/passwd | sort and this will sort alphabetically. To add filter in the result, you can awk -F':' '$1 == "hachiko" { print $1 "\t"  $3 }' /etc/passwd | sort where hachiko is a username you wanted to print with its UID. Hope this helps!

MySQL: Create user and grant a user

Image
To create a user, do create user 'myuser' identified by 'iampassword'; To grant a user, do grant select, alter, alter routine, create, create routine, create temporary tables, create user, create view, delete, drop, execute, file, grant option, index, insert, lock tables, process, references, reload, replication client,replication slave, show databases, show view, update, usage on *.* TO 'ipyrusc'@'localhost'; The strings "select, lock, alter, alter routine, etc..." are privileges that you can select to what privilige you want the user created to have. Note that the 'myuser' is specified when granting the priviliges. To assure this user exist, you can do query by select user,host from mysql.user; to show the users of MySQL . To know more about this, check the page about granting and adding a user at MySQL website .

Just a Quick Guide For iptables

For adding a chain entry:     iptables -A INPUT -p tcp --dport 80 -j ACCEPT     iptables -A INPUT -p tcp --dport 443 -j ACCEPT     iptables -A INPUT -p tcp --dport 21 -j ACCEPT     iptables -A INPUT -p tcp --dport 22 -j ACCEPT     iptables -A INPUT -p tcp --dport 110 -j ACCEPT     iptables -A INPUT -p tcp --dport 143 -j ACCEPT     iptables -A INPUT -p tcp --dport 3000 -j ACCEPT     iptables -A INPUT -j DROP     iptables -I INPUT 8 -p tcp --dport 9999 -j ACCEPT First entry, adds port 80 (http) to be accepted, port 443 (https), port 21 (ftp), port 22 (ssh,scp, sftp), port 110 (pop3), port 143 (imap), port 3000 (custom set port for thin server--a ruby web server). Then, iptables -A INPUT -j DROP  will drop everything that would connect to the server. The last entry iptables -I INPUT 8 -p tcp --dport 9999 -j ACCEPT will insert into the list at ...

CentOS "apxs" command not found

apxs is an Apachec extension tool. I realize that this tool, is by default, not installed under CentOS (or perhaps even RedHat). To fix this, just install it using yum by: yum install httpd-devel.i386 where apxs is installed under "httpd-devel" package. Hope this helps.

Understanding The "yum.conf " and How Does It Like

So, what's a "yum.conf" can do? yum.conf is where you can meet your specific needs and support your own local repositories. This is the route that will almost certainly be taken by most systems administrators who build their own repository. To do this, start by reading the yum.conf man pages that should have come with your distribution. Look over the default /etc/yum.conf that was installed by the RPM. Finally, browse through the additional examples below. Chances are pretty good that one of these will resources will provide a template that is adequate to get you started, and once you get things running at all a bit of experimentation will soon make you an expert. So let's look at a yum.conf file that is fairly minimal - just enough to get you started: [main] cachedir=/var/cache/yum debuglevel=2 logfile=/var/log/yum.log [fedora-core] name = Fedora Core baseurl=http://www.myserver.org/fedora/ gpgcheck=1 Systems persons who are building a fedora mirror as...

CentOS php-common during updating PHP 5.2.13 version trouble

I went stumble with this php-common package which errs when I tried to install the PHP 5.2.13 version. So what I did, I do the command yum whatprovides php-curl And the result gives me the following lines below: Loaded plugins: fastestmirror, priorities Loading mirror speeds from cached hostfile * addons: p3plmirror02.prod.phx3.secureserver.net * base: p3plmirror02.prod.phx3.secureserver.net * extras: p3plmirror02.prod.phx3.secureserver.net * turbopanel-base: p3plmirror02.prod.phx3.secureserver.net * turbopanel-centos5: p3plmirror02.prod.phx3.secureserver.net * update: p3plmirror02.prod.phx3.secureserver.net addons | 951 B 00:00 addons/primary | 201 B 00:00 base ...

Installing swftools on FreeBSD using port tools

Doing a pkg_which swftools show nothing, and swftools needs to be installed. So what I did, I changed directory by cd /usr/ports/graphics/swftools/ then issued command   make install clean and encountered this error ===>   jpeg-8_1 depends on package: libtool>=2.2 - not found ===>   Found libtool-1.5.26, but you need to upgrade to libtool>=2.2. so I issued portupgrade command to upgrade my libtool by   portupgrade -r libtool then cd /usr/ports/graphics/swftools/ yet, another error I encountered. ===>   An older version of graphics/jpeg is already installed (jpeg-6b_7)       You may wish to ``make deinstall'' and install this port again       by ``make reinstall'' to upgrade it properly.       If you really wish to overwrite the old port of graphics/jpeg       without deleting it first, set the variable "FORCE_PKG_REGISTER"   ...

Using sed with backreference as the replacement pattern

Tinkering with sed, I have manage to try using regular expressions using backreferences using the most common \N where N is the number of position inside the parenthesis. Searches and replaces the zoo.color to zoo['color'] or zoo.animals to zoo['animals']: cat zoo.js | sed -E "s/(zoo)(\.)([a-zA-Z0-9]*)/\1['\3']/g"|less \1 = is the characters inside the first parenthesis w/c is the zoo \3 = is the characters inside the third parenthesis which involves alpha-numeric -E will interpret as regular expressions as extended (modern) regular expressions rather than basic regular expressions (BRE's) Another example, you can use this for replacing such a string let say, in a SQL statement, example SQL string: CREATE DEFINER=`mysqluser`@`%` FUNCTION `total`(cost DOUBLE, income DOUBLE, lng2 DOUBLE) RETURNS double And you wanted to remove  DEFINER=`mysqluser`@`%`  and allow  FUNCTION  to be a dynamic string so you'll just need to catch tha...

What is Love and Importance of Love?

Image
First Letter to the Corinthians 12:31.13:1-13. Strive eagerly for the greatest  spiritual gifts . But I shall show you a still more excellent way. If I speak in human and angelic tongues but do not have love, I am a resounding gong or a clashing cymbal . And if I have the gift of prophecy and comprehend all mysteries and all knowledge; if I have all faith so as to move mountains but do not have love, I am nothing. If I give away everything I own, and if I hand my body over so that I may boast but do not have love, I gain nothing. Love is patient, love is kind. It is not jealous, (love) is not pompous, it is not inflated, it is not rude, it does not seek its own interests, it is not quick-tempered, it does not brood over injury, it does not rejoice over wrongdoing but rejoices with the truth. It bears all things, believes all things, hopes all things, endures all things. Love never fails. If there are prophecies, they will be brought to nothing; if tongues, they will cease; if know...