Select Previous and Next Entry based on ID in MySQL

Here is an easy way to select the previous and next entry based on a given ID in MySQL, good for paginations in PHP.

To get the previous entry, query is “SELECT * FROM table_name WHERE id $current_id ORDER BY id ASC LIMIT 1″

You might think it’s easier to use (id – 1) or (id + 1) but it might return errors when id’s are deleted and the count is broken.

Opening Jetdirect port in Linux

Here’s a way to open the jetdirect port on linux, by adding a service wrapper under /etc/xinetd.d/ folder with the name jetdirect. Here is the content:

service jetdirect
{
socket_type = stream
protocol = tcp
wait = no
user = lp
server = /usr/bin/lp
server_args = -d printer1 -o raw
groups = yes
disable = no
}

Restart the xinetd service and run nmap to see if port 9100 has been opened.

Bash Command to get/retrieve a process ID

I had an issue one day with a project one of my colleague was handling. This was due to a process that was currently running in Linux in the background which was needed to be killed first before our binary/application can be started. I searched the web for some solutions to it and found out it was relatively easy, get the PID of the process using “ps” and terminate it by “kill”. Here is how it goes:

$ ps aux | grep processname | grep -v grep | awk '{print $2}'

This command simply gets the entry from ps then prints out only the PID. Next thing to do is get it’s output, then do anything with it, kill it, destroy it, whatever you want. But for now killing it is simple assigning that command to a variable, for instance as $PROCESS_PID then do:

$kill -9 $PROCESS_PID

Officially… Bamboo no more!

BambooJanuary 10 when I hear the news from my sister that Bamboo band has disbanded. This was based from a tweet coming from KC Montero and from their show “The KC Show with Kat” at Wave 89.9 FM. But there were yet no official statements from any member of the band back then. Now, Bamboo has released this much awaited statement. Here is a small part of the official statement:


“Things change. We’ve come to a point where you have to trust your gut, your heart and your head and accept that all things change. The hardest part as always is to know where to pack it up and part ways. We’ve learned that this journey is not only about us but includes all who came along for the trip.

“Family, friends, and of course our front row believers who were there for the best reason at all. To simply listen. So it didn’t come easy win­ding down to this decision.
“So here we go — IT’S OFFICIAL. THE BAND IS OVER.”

 

Bamboo was formed 2002 and composed of composed of Bamboo Mañalac (vocals), Ira Cruz (guitars), Nathan Azarcon (bass), Vic Mercado (drums).

Add Facebook Chat on Pidgin IM

Hi Guys, Happy New Year. This topic I am starting is on how to add the Facebook chat on your Pidgin Instant Messenger. Well, you might ask what’s the use but, for some companies which disallows browsing the Facebook site, here is somewhat a way on how to communication with your FB online friends. Facebook uses XMPP protocol which is readily available in Pidgin.

First things first, you have to retrieve or create a username for your Facebook account, this can be done on the Account Settings on your FB account.

Next, on your Pidgin IM, click on Accounts > Manage Accounts

The image above already has a created FB account in it. To add a new one, click on the Add Button.

Fill in the details needed on the Account Settings Dialog Box, Username to use is the username you provided on your FB Account and Password as well. Protocol should be XMPP or Facebook (XMPP). Domain should be chat.facebook.com.

On the Advanced Tab, uncheck Require SSL/TLS, Connect port should be set to 5222. Now you are ready to go, click on Save and wait for your online friends to appear on the Buddies list.

For a detailed instruction on this howto, plus more graphical instructions, i recommend you to visit http://www.howtogeek.com/howto/12527/easily-add-facebook-chat-to-pidgin/

Have yourself a merry tux Christmas….

Hi Guys, just want to wish you to have a Very Merry Christmas. It’s the time of the year again, of gifts and presents, of Christmas carols, and bountiful feast. But let us not forget the One who has provided us all of these things. And let us not forget it’s real meaning and spirit. Again guys, have a very merry Christmas ( in Filipino “Maligayang Pasko sa inyong lahat!” ) from yours truly together with my wife Maia… :)  Xmas Tux

Face lifted… again!

Hi guys, not that much update this time. I just changed the look/theme of the blogsite. Now using monochrome theme by mono-lab. Seems that the previous theme, due to it’s grungy but good look, has been a favorite theme of several WordPress bloggers. As much as I wanted to create my own theme, I’ve decided to adapt one once again. You can’t blame me, these are such good themes. ;)