Thursday, December 16, 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

Tuesday, October 26, 2010

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.

Wednesday, October 20, 2010

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 index number where the process id is located. If  you have some alias with your grep, don't forget to unalias it just to assure, because I do have a alias for my grep having -rn on it.

Hope this helps, with just one command, it would make your life easy. You can make this as an alias if you want also.


Additionally, you can also do,

kill -9 $(ps -re|grep -rE sl1 | awk -F ':' '{ print $3}'| awk '{print $1}')

Wednesday, October 13, 2010

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

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.

Monday, October 4, 2010

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
User-Agent: NuSOAP/0.7.3 (1.114)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 1189

   <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:Created>2010-10-04T17:24:48Z</wsu:Created>
            <wsu:Expires>2010-10-04T17:25:48Z</wsu:Expires>
        </wsu:Timestamp>
        <wsse:UsernameToken>
            <wsse:Username>testusername</wsse:Username>
            <wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>testpassword</wsse:Password>
        </wsse:UsernameToken>
      </wsse:Security>
  </s:Header>
      <GetTransactions xmlns='http://testapi.com/api/loyaltyaccount/v2'><id>411018</id><startDate>2010-09-18T18:00:00</startDate><endDate>2010-09-22T18:20:00</endDate></GetTransactions></s:Body>
</s:Envelope>



Server's response example:





HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Content-Type: text/xml;charset=ISO-8859-1
Content-Length: 7130
Date: Mon, 04 Oct 2010 17:02:53 GMT
Connection: close

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetTransactionsResponse
<loyaltyTransactions>
<ns2:id>2100334</ns2:id>
<ns2:createdAt>2010-09-18T22:55:51.458Z</ns2:createdAt>
<ns2:updatedAt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true" />
<amount>120</amount>
<balance>600</balance>
xsi:nil="true" />
<loyaltyAccountId>411018</loyaltyAccountId>
<loyaltyProgramId>3</loyaltyProgramId>
<pincodeId>439080117</pincodeId>
<pincode>8020-003888H0F732</pincode>
xsi:nil="true" />
xsi:nil="true" />
xsi:nil="true" />
<productPurchaseId xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true" />
xsi:nil="true" />
xsi:nil="true" />
<optionalDetails>PIN Code 8020-003888H0F732</optionalDetails>
</loyaltyTransactions>
<loyaltyTransactions>
<ns2:id>2100434</ns2:id>
<ns2:createdAt>2010-09-22T18:18:18.831Z</ns2:createdAt>
<ns2:updatedAt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true" />
<amount>123</amount>
<balance>2553</balance>
<description>Balance Updated:another test on 2:19pm</description>
<loyaltyAccountId>411018</loyaltyAccountId>
<loyaltyProgramId>3</loyaltyProgramId>
xsi:nil="true" />
xsi:nil="true" />
xsi:nil="true" />
xsi:nil="true" />
xsi:nil="true" />
<productPurchaseId xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true" />
xsi:nil="true" />
xsi:nil="true" />
<optionalDetails>Balance Updated:another test on 2:19pm
</optionalDetails>
</loyaltyTransactions>
</GetTransactionsResponse>
</soap:Body>
</soap:Envelope>


Afterwards, I do copy paste the stuff that I have and just edit it if you have another sub-URI for your service. I think it's faster this way, for development purposes only, but not ideally for QA. Still, scripts as client like Java, PHP, Python, Ruby is of course ideal since you need automation specially when you do continuous integration.

Hope this helps.

Tuesday, September 28, 2010

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 TRIGGER "TMP_PRODUCT_ID" BEFORE
  INSERT ON TMP_PRODUCT FOR EACH ROW WHEN (NEW.ID IS NULL) BEGIN
  SELECT SEQ_TMP_PRODUCT.NEXTVAL INTO :NEW.ID FROM DUAL;
END;


Just that simple.  Just be sure with the table names, sequence names as you might confuse if you base on that sample I have.

Hope that helps.

Wednesday, July 28, 2010

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.

Tuesday, July 20, 2010

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.

Thursday, July 8, 2010

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

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,

Photobucket


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,

Photobucket


Hope this helps.

Wednesday, July 7, 2010

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.

Monday, June 14, 2010

Incompatibility of iconv for PHP 5.2.13 under Mac OS X

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-libxml-dir=/opt/local --with-zlib=/opt/local --disable-cgi --with-ldap=/opt/local --with-apxs2=/usr/sbin/apxs --with-mysqli=/opt/local/lib/mysql/bin/mysql_config --with-openssl --with-mcrypt=/opt/local/ --with-mysql=/opt/local/lib/mysql/ --with-curl=/opt/local --enable-mbstring --with-gd --with-jpeg-dir=/opt/local --with-png-dir=/opt/local --with-freetype-dir=/opt/local --with-t1lib=/opt/local --enable-gd-native-ttf --with-ttf=/opt/local --with-pgsql=/usr/local/pgsql/ --with-iconv=/usr/local 
And when I run "make" I do got these errors,

Undefined symbols:
  "_libiconv_open", referenced from:
      _do_convert in gdkanji.o
      __php_iconv_strlen in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strpos in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_substr in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _php_iconv_stream_filter_factory_create in iconv.o
  "_libiconv", referenced from:
      _do_convert in gdkanji.o
      __php_iconv_strlen in iconv.o
      _php_iconv_string in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_appendl in iconv.o
      __php_iconv_appendl in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _php_iconv_stream_filter_append_bucket in iconv.o
      _php_iconv_stream_filter_append_bucket in iconv.o
     (maybe you meant: __libiconv_version)
  "_libiconv_close", referenced from:
      _do_convert in gdkanji.o
      __php_iconv_strlen in iconv.o
      _php_iconv_string in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strpos in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_substr in iconv.o
      _php_iconv_stream_filter_dtor in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1
 I guess this is a bug from PHP in which it only base for the libiconv library under /usr/lib directory, and my fix for this is by copying the libiconv I have recently compiled from /usr/local/lib/ with the current one, which is the /usr/lib/libiconv.* files.
So I did,

cd /usr/lib
mkdir iconv_backup
mv libiconv.* iconv_backup
cp -rf /usr/local/lib/libiconv.* .
cp -rf iconv_backup/* /usr/local/lib/
Now, running make compiles the source code of PHP successfully.

Caveat for this, my purpose of switching the libiconv files is because I have Adium and Adium isn't compliant with the libiconv in which I have recently compiled as x86_64 architecture or 64 bit, so having them under /usr/lib/iconv_backup, I run Adium thru terminal by /Applications/Adium.app/Contents/MacOS/Adium and it works good now.

Hope this helps!

Tuesday, May 11, 2010

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 ;-).

Sunday, May 2, 2010

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 the file.

Hope this helps! 


Thursday, April 29, 2010

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.

Wednesday, April 28, 2010

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 and CentOS as well as Fedora.

Links that might be useful also on configuring or getting this repositories are
http://blog.famillecollet.com/pages/Config-en
http://fedoraproject.org/wiki/EPEL

Tuesday, April 27, 2010

tesseract compile with libtiff

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!

Monday, April 26, 2010

MySQL: Create user and grant a user

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 the 8 row of the entry, this is useful when you will be setting a specific priority of filtering a port.

To delete an entry, you can do,
 iptables -D INPUT 2
 to delete the second row of the list, list can be viewed by issuing the command
iptables -L
 To flush all the result, you can do
iptables -F

To add a chain that would only be specific to port intervals, let say, ban all the port that goes from port 20 - port 80, you can execute or add
iptables -A INPUT -p tcp --dport 20:80 -m state --state NEW,ESTABLISHED -j REJECT

where --dport specifies the 20:80 (colon as the delimiter), and -m for extended match and may load extension (here the state), and --state for specifying the states (valid states are INVALID, NEW, ESTABLISHED), and -j to reject the attempt of opening a connection.

 To save your rules, you can execute
iptables-save > /etc/sysconfig/iptables
if your iptables config is in that directory path.

Sunday, April 25, 2010

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.

Wednesday, April 21, 2010

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 we proceed should note that this yum.conf uses the repository we ``built'' in the previous section, where of course the actual URL should point to that repository.   Users who want to accomplish the same thing could instead paste in an entry from the list of public yum repositories linked above.  For example, here is a yum.conf file containing several repositories from that list:

[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log

[fedora-stable-9]
name=Fedora Project Stable RPMS for RHL 9
baseurl=http://download.fedora.us/fedora/redhat/9/i386/yum/stable/
gpgcheck=1

[fedora-updates-9]
name=Fedora Project update RPMS for RHL 9
baseurl=http://download.fedora.us/fedora/redhat/9/i386/yum/updates/
gpgcheck=1

From the comments, one could hope that these two repositories contain what is effectively Red Hat 9, as ported into the Fedora project, plus updates. Note that we've turned on gpgcheck under the assumption that this is a good thing to do to ensure that the RPMs we grab haven't been trojanned.

Note that yum has many options that can be selected in the yum.conf file, only a few of which are illustrated in these examples. Each baseurl can have additional fallback repositories for additional stability and robustness. gpgchecking can be enabled (causing each rpm to be examined to ensure that it is correctly signed).

The debuglevel can be cranked up or down to help diagnose problems. pkgpolicy can be set to determine the order in which yum chooses to decide between two versions of the same package on different repositories it is using at the same time. Packages can be listed to exclude them from the automated update process.

The failover method yum uses to select a server to use from a list of servers in a baseurl can be chosen. More options may have been added since this article was written, or old options may have gone away.
 
So read the man pages on yum.conf. It is the only thing likely to be authoritative.
At this point we will assume that you are on a client, that you have a functional /etc/yum.conf installed that directs your system to a repository (that you built yourself or not) that is consistent with your system's existing RPM distribution, and that yum list works (as root) to list packages on the repository. Now let's see what yum can do.

Tuesday, April 20, 2010

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 | 2.1 kB 00:00
base/primary_db | 1.6 MB 00:00
extras | 1.1 kB 00:00
extras/primary | 107 kB 00:00
extras 325/325
turbopanel-base | 951 B 00:00
turbopanel-base/primary | 72 kB 00:00
turbopanel-base 494/494
turbopanel-centos5 | 951 B 00:00
turbopanel-centos5/primary | 2.1 kB 00:00
turbopanel-centos5 8/8
update | 1.9 kB 00:00
update/primary_db | 463 kB 00:00
php-common-5.1.6-23.2.el5_3.i386 : Common files for PHP
Repo : base
Matched from:
Other : php-curl



php-common-5.1.6-24.el5_4.5.i386 : Common files for PHP
Repo : update
Matched from:
Other : php-curl



php-common-5.3.2-1.i386 : Common files for PHP
Repo : installed
Matched from:
Other : Provides-match: php-curl


Indeed, I do have 5.3.2--the latest PHP release, as of this posting--but I do need yet 5.2 version because of incompatibilities with the code which has done thru a rigorous testing.

Since php-common has (-) dash inside the string, so I issue this command to remove the package php-common

yum remove php*5*3*
My main purpose of removing it was that, I installed the PHP 5.3 which is not the needed version of PHP I want, and php-common confuses the installation/update, indeed backward installation.

After this, installing PHP by issuing the command
yum --disablerepo=* --enablerepo=webtatic --exclude=php*5.3* install php

installs everything that I need. Notice the repository named "webtatic", I installed this repo from it's website, or read this link how did I grab it or you can also try this repo from remi


Issuing the command

php -v

shows

PHP 5.2.13 (cli) (built: Feb 28 2010 16:22:50)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
Hope this makes helpful.

Sunday, March 14, 2010

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"
      in your environment or the "make install" command line.
*** Error code 1


Then jpeg needs to be upgraded, I did uninstall the jpeg tool located in "graphics/jpeg" under ports directory thru command:
cd ../jpeg
make deinstall
make reinstall

then I go back to 

cd /usr/ports/graphics/swftools/

and install thru command

make install clean

After installation is finished, try issuing the command pdf2swf to test if it's properly installed and here's what I got:
Usage: pdf2swf [-options] file.pdf -o file.swf

-h , --help                    Print short help message and exit
-V , --version                 Print version info and exit
-o , --output file.swf         Direct output to file.swf. If file.swf contains '%' (file%.swf), then each page goes to a seperate file.
-p , --pages range             Convert only pages in range with range e.g. 1-20 or 1,4,6,9-11 or
-P , --password password       Use password for deciphering the pdf.
-v , --verbose                 Be verbose. Use more than one -v for greater effect.
-z , --zlib                    Use Flash 6 (MX) zlib compression.
-i , --ignore                  Allows pdf2swf to change the draw order of the pdf. This may make the generated
-j , --jpegquality quality     Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)
-s , --set param=value         Set a SWF encoder specific parameter.  See pdf2swf -s help for more information.
-w , --samewindow              When converting pdf hyperlinks, don't make the links open a new window. 
-t , --stop                    Insert a stop() command in each page. 
-T , --flashversion num        Set Flash Version in the SWF header to num.
-F , --fontdir directory       Add directory to the font search path.
-b , --defaultviewer           Link a standard viewer to the swf file. 
-l , --defaultloader           Link a standard preloader to the swf file which will be displayed while the main swf is loading.
-B , --viewer filename         Link viewer filename to the swf file. 
-L , --preloader filename      Link preloader filename to the swf file. 
-q , --quiet                   Suppress normal messages.  Use -qq to suppress warnings, also.
-S , --shapes                  Don't use SWF Fonts, but store everything as shape.
-f , --fonts                   Store full fonts in SWF. (Don't reduce to used characters).
-G , --flatten                 Remove as many clip layers from file as possible. 
-I , --info                    Don't do actual conversion, just display a list of all pages in the PDF.
-Q , --maxtime n               Abort conversion after n seconds. Only available on Unix.

so it's installed now. After I see it's already installed, I issued the command 

pkg_add -r swftools

However, I got an error

Error: FTP Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.3-release/Latest/swftools.tbz: File unavailable (e.g., file not found, no access)
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.3-release/Latest/swftools.tbz' by URL
root@mullimps21:/usr/ports/graphics/swftools > pkg_add -r swftools-0.9.0_2
Error: FTP Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.3-release/Latest/swftools-0.9.0_2.tbz: File unavailable (e.g., file not found, no access)
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.3-release/Latest/swftools-0.9.0_2.tbz' by URL

but that's ok. pkg_add command installs the package to put under pakage list



So that's all I did. Hope this helps ;-)

Tuesday, February 9, 2010

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 that string. So you can use backreferences with sed.

$> cat query.sql | sed -e 's/DEFINER.*\@.*\s\([A-Za-z]*\)\s`/\'1' `/g'

result:

CREATE FUNCTION `total`(cost DOUBLE, income DOUBLE, lng2 DOUBLE) RETURNS double


Hope this helps.

Sunday, January 31, 2010

What is Love and Importance of Love?

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 knowledge, it will be brought to nothing. For we know partially and we prophesy partially, but when the perfect comes, the partial will pass away. When I was a child, I used to talk as a child, think as a child, reason as a child; when I became a man, I put aside childish things. At present we see indistinctly, as in a mirror, but then face to face. At present I know partially; then I shall know fully, as I am fully known. So faith, hope, love remain, these three; but the greatest of these is love.