C3rd
PHP: Pagination | Paginator
Posted: 12 Feb 2011, 10:00am - Saturday[caption id="attachment_520" align="alignright" width="304" caption="Pagination Screenshot"]
[/caption]
Last month, my classmate ask me how to create a pagination or paginator that can handle hundred of thousands of rows. And I realized that my current paginations are not good enough. It must be dynamic as possible. So, I created one. I tried this last-last week, but I didn't completed it since I'm very busy for that past few weeks. Just now, I got a chance to solve the problem.
Before that, this is my old pagination;

function paginationTest($offset = 0, $css = 'padding: 5px 5px 5px 5px; border-top: 1px #D7D7D7 dashed; text-align: right;') { global $cfgMax; global $globalProjectID; $MAXPAGE = $cfgMax; //$MAXPAGE = 2; $sqlQ = "SELECT * FROM pagetest"; $result = mysql_query( sprintf( $sqlQ ) ); $MaxValue = mysql_num_rows($result); $MaxPerPage = $MAXPAGE; $OffSet = 0; $PageCounter = 1; $TotalPages = ceil( $MaxValue / $MaxPerPage ); if ($MaxValue >= $MAXPAGE) { $rdata = '<div style="'.$css.'">Page: '; for ($i = 0; $i < $TotalPages; $i++) { $OffSet = $MaxPerPage * $i; if ($OffSet == $offset) { $rdata .= ' '.($i + 1).' '; } else { $rdata .= ' <a href="pagination.php?offset='.$OffSet.'">'.($i + 1).'</a> '; } } return $rdata.'</div>'; } else { return ' '; } }And here's my new pagination... :)
function paginationTest($page = 1, $cssContainer = 'padding: 5px 5px 5px 5px; border-top: 1px #D7D7D7 dashed; text-align: right;', $cssLink = '', $cssCurrent = '') { global $MAXPAGE; if ($page == 0) { $page = 1; } $sqlQ = "SELECT COUNT(id) FROM pagetest"; $result = mysql_query( sprintf( $sqlQ ) ); $tmp = mysql_fetch_row($result); $MaxValue = $tmp[0]; unset($tmp); mysql_free_result($result); $MaxPerPage = $MAXPAGE; $endPage = $MaxValue / $MAXPAGE; $endPage = ceil($endPage); if ($page <= 5) { $start = 1; $end = 10; } else { if (($page + 5) > $endPage) { $start = $endPage - 9; $end = $endPage; } else { $start = $page - 4; $end = $page + 5; } } $rdata = '<div style="'. $cssContainer .'">'; if ($MaxValue >= $MAXPAGE) { if ($page > 5) { /* DEFINITION: if previous is the previous page NOTES: if you like this pagination, just uncomment this and comment the other method (line 116) */ //$prevPage = $page - 1; /* DEFINITION: sif previous is the page block NOTES: if you like this pagination, just uncomment this and comment the other method (line 110) */ $prevPage = $start - 1; $rdata .= ' <a href="pagination.php?offset=0" class="'.$cssLink.'">«</a> '; $rdata .= ' <a href="pagination.php?offset='.$prevPage.'" class="'.$cssLink.'"><</a> '; } for ($i = $start; $i <= $end; $i++) { if ($page == $i) { $rdata .= ' <a href="javascript:alert(\'Page already shown!\');" class="'.$cssCurrent.'">'.$i.'</a> '; } else { $rdata .= ' <a href="pagination.php?offset='.$i.'" class="'.$cssLink.'">'.$i.'</a> '; } } if (($page + 5) < $endPage) { /* DEFINITION: if next is the next page NOTES: if you like this pagination, just uncomment this and comment the other method (line 144) */ //$nextPage = $page + 1; /* DEFINITION: if next is the page block NOTES: if you like this pagination, just uncomment this and comment the other method (line 138) */ $nextPage = $end + 1; $rdata .= ' <a href="pagination.php?offset='.$nextPage.'" class="'.$cssLink.'">></a> '; $rdata .= ' <a href="pagination.php?offset='.$endPage.'" class="'.$cssLink.'">»</a>'; } } else { $rdata = ' '; } $rdata .= '</div>'; return $rdata; }that's it... :) Hope this would help ...
- Download Source: pagination_v2.0.zip
Epoch Time
Posted: 18 Oct 2010, 21:44pm - MondayI saved this information due to I used it all the time in my programming either PHP, JavaScript nor Visual C#. I found very very useful.. :)
--------------------------------------------
-----------------------------------
Reference: http://www.epochconverter.com
What is epoch time?
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). Literally speaking the epoch is Unix time 0 (midnight 1-1-1970), but 'epoch' is often used as a synonym for 'Unix time'. Many Unix systems store epoch dates as a signed 32-bit integer, which might cause problems on January 19, 2038 (known as the Year 2038 problem or Y2038).Human readable time | Seconds |
1 minute | 60 seconds |
1 hour | 3600 seconds |
1 day | 86400 seconds |
1 week | 604800 seconds |
1 month (30.44 days) | 2629743 seconds |
1 year (365.24 days) | 31556926 seconds |
How to get the current epoch time in ...
Convert from human readable date to epoch
Perl | Use these Perl Epoch routines |
PHP | mktime(hour, minute, second, month, day, year) ![]() |
Ruby | Time.local(year, month, day, hour, minute, second, usec ) (or Time.gm for GMT/UTC input). To display add .to_i |
Python | import time first, then int(time.mktime(time.strptime('2000-01-01 12:34:00', '%Y-%m-%d %H:%M:%S'))) - time.timezone |
Java | long epoch = new java.text.SimpleDateFormat ("dd/MM/yyyy HH:mm:ss").parse("01/01/1970 01:00:00"); |
VBScript/ASP | DateDiff("s", "01/01/1970 00:00:00", time field) ![]() |
MySQL | SELECT unix_timestamp(time) Time format: YYYY-MM-DD HH:MM:SS or YYMMDD or YYYYMMDD
More on using Epoch timestamps with MySQL |
PostgreSQL | SELECT extract(epoch FROM date('2000-01-01 12:34'));
With timestamp: SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-08');
With interval: SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours'); |
SQL Server | SELECT DATEDIFF(s, '1970-01-01 00:00:00', time field) |
JavaScript | use the JavaScript Date object |
Unix/Linux Shell | date +%s -d"Jan 1, 1980 00:00:01" Replace '-d' with '-ud' to input in GMT/UTC time. |
Convert from epoch to human readable date
Perl | Use these Perl Epoch routines |
PHP | date(output format, epoch); Output format example: 'r' = RFC 2822 date ![]() |
Ruby | Time.at(epoch) |
Python | import time first, then time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime(epoch)) Replace time.localtime with time.gmtime for GMT time. ![]() |
Java | String date = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date (epoch*1000)); |
VBScript/ASP | DateAdd("s", epoch, "01/01/1970 00:00:00") ![]() |
MySQL | from_unixtime(epoch, optional output format) The default output format is YYY-MM-DD HH:MM:SS more ... |
PostgreSQL | PostgreSQL version 8.1 and higher: SELECT to_timestamp(epoch); ![]() SELECT TIMESTAMP WITH TIME ZONE 'epoch' + epoch * INTERVAL '1 second'; |
SQL Server | DATEADD(s, epoch, '1970-01-01 00:00:00') |
Microsoft Excel | =(A1 / 86400) + 25569 Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number). For other timezones: =((A1 +/- timezone adjustment) / 86400) + 25569. |
Crystal Reports | DateAdd("s", {EpochTimeStampField}-14400, #1/1/1970 00:00:00#) -14400 used for Eastern Standard Time. See Timezones. |
JavaScript | use the JavaScript Date object |
Unix/Linux Shell | date -d @1190000000 Replace 1190000000 with your epoch, needs recent version of 'date'. Replace '-d' with '-ud' for GMT/UTC time. |
PowerShell | Function get-epochDate ($epochDate) { [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($epochDate)) } , then use: get-epochDate 1279152364 . Works for Windows PowerShell v1 and v2 |
Other OS's | Command line: perl -e "print scalar(localtime(epoch))" (If Perl is installed) Replace 'localtime' with 'gmtime' for GMT/UTC time. |
dev-C++: Bank Queue Simulation using Graphic
Posted: 8 Sep 2010, 0:18am - WednesdayAgain, I'm not good in C++. Yet I managed to finish my assignment in Advanced Data Structure for MIT. As required, I need to use graphic.h and struct (structure type variables) in dev-C++ to create Bank Queue Simulation.
[caption id="attachment_448" align="aligncenter" width="577" caption="theBank Sim Screenshot"]
[/caption]

Here's the Demo Executable file: theBank.exe
Source Code: theBank.zip
dev-C++ : Bubble Sort with Graphic Plotting
Posted: 24 Jul 2010, 21:01pm - SaturdayI'm having difficulties in creating good programming algorithm with C++. I find its very difficult. Somehow, I would like to share my accomplishment in creating this program, Bubble Sort with Graphic Plotting. But first, what is bubble sort?
Bubble sort is a simple sorting algorithm. It works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort.
Below is the demo, source codes and libraries needed...
If you have better algorithm solutions, if you don't mind, can you email it to me... Like to see how others solve the problem.
MySQL: Understanding "On Update/Delete Cascade" Statement
Posted: 27 May 2010, 23:36pm - ThursdayThis is a re-post article, I found it as significant answer on MySQL "On Cascade" statement. Thanks to Marc B @ StackOverflow.
I want to use foreign keys to keep the integrity and avoid orphans (I already use innoDB).
How do I make a SQL statment that DELETE ON CASCADE?
If I delete a category then how do I make sure that it would not delete products that also are related to other categories.
The pivot table "categories_products" creates a many-to-many relationship between the two other tables
categories - id (INT) - name (VARCHAR 255) products - id - name - price categories_products - categories_id - products_idANSWER: If your cascading deletes nuke a product because it was a member of a category that was killed, then you've set up your foreign keys improperly. Given you example tables, you should have the following table setup:
CREATE TABLE categories ( id int unsigned not null primary key, name varchar(255) default null ); CREATE TABLE products ( id int unsigned not null primary key, name varchar(255) default null ); CREATE TABLE categories_products ( category_id int unsigned not null, product_id int unsigned not null, PRIMARY KEY (category_id, product_id), KEY pkey (product_id), FOREIGN KEY (category_id) REFERENCES categories (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (product_id) REFERENCES products (id) ON DELETE CASCADE ON UPDATE CASCADE, );This way, you can delete a product OR a category, and only the associated records in categories_products will die alongside. The cascade won't travel farther up the tree and delete the parent product/category table. e.g.
products: boots, mittens, hats, coats categories: red, green, blue, white, black prod/cats: red boots, green mittens, red coats, black hatsf you delete the 'red' category, then only the 'red' entry in the categories table dies, as well as the two entries prod/cats: 'red boots' and 'red coats'. The delete will not cascade any farther and will not take out the 'boots' and 'coats' categories. comment followup: you're still misunderstanding how cascaded deletes work. They only affect the tables in which the "on delete cascade" is defined. In this case, the cascade is set in the "categories_products" table. If you delete the 'red' category, the only records that will cascade delete in categories_products are those where
category_id = red
. It won't touch any records where 'category_id = blue', and it would not travel onwards to the "products" table, because there's no foreign key defined in that table.
Here's a more concrete example:
categories: products: +----+------+ +----+---------+ | id | name | | id | name | +----+------+ +----+---------+ | 1 | red | | 1 | mittens | | 2 | blue | | 2 | boots | +---++------+ +----+---------+ products_categories: +------------+-------------+ | product_id | category_id | +------------+-------------+ | 1 | 1 | // red mittens | 1 | 2 | // blue mittens | 2 | 1 | // red boots | 2 | 2 | // blue boots +------------+-------------+Let's say you delete category #2 (blue):
DELETE FROM categories WHERE (id = 2);the DBMS will look at all the tables which have a foreign key pointing at the 'categories' table, and delete the records where the matching id is 2. Since we only defined the foreign key relationship in
products_categories
, you end up with this table once the delete completes:
+------------+-------------+ | product_id | category_id | +------------+-------------+ | 1 | 1 | // red mittens | 2 | 1 | // red boots +------------+-------------+There's no foreign key defined in the
products
table, so the cascade will not work there, so you've still got boots and mittens listed. There's just no 'blue boots' and no 'blue mittens' anymore.
--
Reference: http://stackoverflow.com/questions/2914936/mysql-foreign-key-constraints-cascade-delete by Marc B.
Prototype POS System - Transparent GUI
Posted: 23 Apr 2010, 16:48pm - FridayPOS System - Transparent GUI
My article is about a prototype POS system for grocery stores or 24 hours mini marts using Transparency graphical user interface.
Transparency in MS Visual C# works similar to chroma keys in Adobe After Effects or Premiere. All you have to do is set a color key to make it transparent.
- As you create a form as Form1, go to Form1 properties and set TransparencyKey to Black.
- Then set your Backcolor of your form to Black.
- In Photoshop or any image editing tools, create an GUI or layout design then save as PNG format.
- In Form1 properties, set BackgroundImage and select the PNG image you created from Photoshop or other image editing tools.
- Set also the FormBorderStyle to None and Opacity to 95%.
- Then run your project. You'll see the transparency works well. :)
Everyday Brown-out ordered by Politicians from Above
Posted: 3 Mar 2010, 10:22am - WednesdayThis scheduled brown-out in Iligan City and all over the Philippines, does really about El Niño? I don't think so! Let me reveal the truth to you.
One of the employee from NAPOCOR I talked to and he said, "It is an order from above... It's not El Niño. There are enough water to supply the turbine of NAPOCOR. I think this is political strategy."
See folks, do not believe in the TV news or newspaper saying that its about El Niño! Fuck them! For my analysis, this is just a strategy to take down the Election 2010. Or let's just say someone really want to cheat or desperate to win for power and greed. Well, if GMA fuck up FPJ... Then she can do it again to let her presidential bet win.
I believe Philippines will just be a junkyard in the future. Just like Somalia nor Niger.
There's no hope for these people. Everybody is running for the money... For their glorified greed! *sigh!* God help us! Let the Philippine islands sink to the bottom of the sea, just like Atlantis!

Ubuntu Professional Certification
Posted: 18 Dec 2009, 22:11pm - Friday[caption id="attachment_302" align="alignright" width="220" caption="Ubuntu Girl"]
[/caption]
Today, I tried to answer the pre-test of UPC or the Ubuntu Professional Certification... and the result was...

Dear Camilo III, Thank you very much for taking part in the pre-training assessment. Your score is 9, which means that you are probably over-qualified for this course. As a next step we suggest that you read through the Deploying Ubuntu Server Edition course overview found here: http://www.ubuntu.com/training/certificationcourses/server and then complete the corresponding online assessment. Ubuntu Training courses are taught by Canonical-trained Ubuntu Certified Instructors. The Deploying Ubuntu Server Edition course is available through online training and classroom training, so you can can learn in the environment that suits you best. Visit: www.ubuntu.com/training for more information. Best regards and good luck The Ubuntu Training TeamHow flattering!! I admit it, I'm not that good... but anyway, the test is so easy.. hahahaha.. :) And one thing, I don't have a dollars to pay the $1,600 for the Deploying Ubuntu Server Edition Certification. Its like PhP 76,800.00 in my country, that is 9 months to save my whole salary. hahahaha.. Damn! I will starved to death if I will take the exam... :P
[PHP] Converting a value to MAC address format
Posted: 20 Oct 2009, 23:37pm - Tuesday
function convertMACAddress($input) { // clean up unwanted characters $input = preg_replace( '/[^a-zA-Z0-9]/', '', $input); // initiate character positioning $pos = 0; // declare output container $output = ''; // if given MAC is invalid, terminate process and return an error if (strlen($input) < 12) { return '[Unrecognized MAC address]'; } // initiate convertion... for ($i = 0; $i < 6; $i++) { if ($i == 0) { $output .= substr($input, $pos, 2); } else { $output .= ':'.substr($input, $pos, 2); } $pos += 2; } return $output; }That's it... Problem solved. :) If need a sample code, please download the source -> mac.convert.zip -- Have fun coding..
Attacks in Mindanao
Posted: 10 Jul 2009, 8:30am - Friday
- Bombing of Maria Christina Bridge in Iligan City (April 20, 2009) - It seems the election is so near, all bombs away where the money comes. I think 64M has been released for the repair. And many months later from the released date, there no repair happened. Again, its a play to get the money from above.
- Bombing of Sabayle Street, Iligan City (July 6, 2009 -- includes also other places in Mindanao) - I think it all about the charter change. Since they want to change the constitution, they want to declare martial law by using the terrorist act and somehow, they were the terrorist.
Pingering - Free Ping Utility Tool for SEO
Posted: 27 Jan 2011, 18:02pm - ThursdayYesterday, my friend Elvar ask me to create a tool for his SEO campaign. So since I have nothing to do even though my Adv. Stats exam is 2 days ahead yet I haven't read my notes even a glance, I still have a change to create this tiny tool for Elvar, you and to whom who need it somewhere out there in the vast space of the cyber world. :)
Download: Pingering.exe
By the way, if your running on Windows XP and older version of Windows, please install .NetFramework before running the Pingering.
Download .NetFramework 2.0: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5&displaylang=en
Planet Gliese 581g
Posted: 2 Oct 2010, 20:22pm - SaturdaySince I was a kid, I dream to be part of interstellar exploration... And now a new planet has been found and called Planet Gliese 581g, the feeling being part of the exploration team is tinkling my thoughts again... If ever there's a advanced space craft will be built for the voyage to Planet Gliese 581g, I wish I could join the team as Water boy or Decoy for Alien Monsters. Bwuahahaha.. Distance is 20 light years and 1.17569996 × 1014 in miles. Whoah! That is so far! I will miss my dogs badly by that time reached in Planet Gliese 581g.. bwuahhahaha...
Hey NASA, let me join in to your team... :)
Reference:
- http://news.yahoo.com/s/time/08599202248900
- http://news.yahoo.com/s/space/20100930/sc_space/alienworldtourtheexoplanetsaroundstargliese581
- http://www.space.com/scienceastronomy/earth-like-exoplanet-possibly-habitable-100929.html
- http://www.space.com/php/multimedia/imagedisplay/img_display.php?pic=earth-like-planet-100929-02.jpg&cap=This+artist%27s+conception+shows+the+inner+four+planets+of+the+Gliese+581+system+and+their+host+star%2C+a+red+dwarf+star+only+20+light+years+away+from+Earth.+The+large+planet+in+the+foreground+is+the+newly+discovered+GJ+581g%2C+which+has+a+37-day+orbit+right+in+the+middle+of+the+star%27s+habitable+zone+and+is+only+three+to+four+times+the+mass+of+Earth%2C+with+a+diameter+1.2+to+1.4+times+that+of+Earth.+Credit%3A+Lynette+Cook+[%3Ca+href%3Dhttp%3A%2F%2Fwww.space.com%2Fscienceastronomy%2Fearth-like-exoplanet-possibly-habitable-100929.html%3EFull+Story%3C%2Fa%3E]
- http://www.space.com/php/multimedia/imagedisplay/img_display.php?pic=gliese-581-exoplanet-100929-02.jpg&cap=The+orbits+of+planets+in+the+Gliese+581+system+are+compared+to+those+of+our+own+solar+system.+The+Gliese+581+star+has+about+30+percent+the+mass+of+our+sun%2C+and+the+outermost+planet+is+closer+to+its+star+than+we+are+to+the+sun.+The+4th+planet%2C+G%2C+is+a+planet+that+could+sustain+life.+Credit%3A+Zina+Deretsky%2C+National+Science+Foundation+[%3Ca+href%3Dhttp%3A%2F%2Fwww.space.com%2Fscienceastronomy%2Fearth-like-exoplanet-possibly-habitable-100929.html%3EFull+Story%3C%2Fa%3E]
- http://www.universetoday.com/74679/could-chance-for-life-on-gliese-581g-actually-be-100/
Algorithm: Graphic Sort
Posted: 8 Aug 2010, 16:14pm - Sunday
[caption id="attachment_438" align="aligncenter" width="480" caption="Graphic Sort"]
[/caption]
Today, I created different kinds of sorting.

- Bubble sort
- Selection sort
- Insertion sort
- Quick sort
IPTABLES - Logging and dropping traffic in a single rule
Posted: 15 Jul 2010, 20:00pm - ThursdayMany people who are familiar with IPCHAINS (the predecessor to IPTABLES) are familiar with the ability to simply tack on a '-l' to also log rules which match that rule. In IPTABLES this is not done the same way and no such option exists.
To accomplish the same task in IPTABLES you could simply put a identical rule with a LOG action before every drop rule, but that will fill your script with copies of the same rule and force updates in multiple locations. This is therefore not an ideal solution.
The cleanest method of accomplishing this is to create a new chain which does both the LOG and DROP for you. The following IPTABLES rules will create a LOGDROP chain.
The second rule flushes the contents of the chain, again, so that if you run it twice on the same system you don't have duplicate rules in the chain. The third rule LOGS the traffic with the added "LOGDROP" prefix and the fourth rule DROPs the traffic What this now means is that you can easily log and drop traffic or even log and accept traffic (with minor modifications to the above), by creating a rule such as this:# Create the LOGDROP chain iptables -N LOGDROP > /dev/null 2> /dev/null iptables -F LOGDROP iptables -A LOGDROP -j LOG --log-prefix "LOGDROP " iptables -A LOGDROP -j DROPThe first rule in this set creates the new chain. The output is sent to /dev/null because if you attempt to run this twice on the same system, you will get an error saying the chain already exists. It's up to you if you want to see that message or not.
If anyone has any comments or corrections for this, please let me know using the comment system below. Article From: http://www.techbytes.ca/techbyte136.html# Log and drop all connections to the HTTP port iptables -A INPUT -p tcp --dport 80 -j LOGDROPAs you can see, you now simply use the LOGDROP target in order to log and drop any traffic you want. You must ensure that you define the LOGDROP target BEFORE you attempt to use it in a rule.
Generating SSL certificates using OpenSSL
Posted: 10 May 2010, 12:56pm - MondayBased on Centos Wiki on HowTo SSL - http://wiki.centos.org/HowTos/Https
I simplified the procedure to create a bash script. Here's the code;
Or download the script below... Download: gencert.zip bash script How to add gencert command to your system:#!/bin/bash umask 077 echo "" if [ $# -eq 0 ] ; then echo $"Usage: `basename $0` <DOMAIN_NAME> [...]" echo "" exit 0 fi for target in $@ ; do keyFile=${target}.key crtFile=${target}.crt csrFile=${target}.csr echo $keyFile echo $crtFile echo $csrFile # Generate private key openssl genrsa -out $keyFile 1024 # Generate CSR openssl req -new -key $keyFile -out $csrFile echo "" echo "Please enter the number of days which SSL Certificate will be valid:" read DAYS echo "" # Generate Self Signed Key openssl x509 -req -days $DAYS -in $csrFile -signkey $keyFile -out $crtFile done
- Download the gencert bash script
- Extract the file
- chmod u+x gencert
- then copy the gencert file to /bin/
- Wallaah! You're done!
Bayan ko walang pag-asa...
Posted: 21 Apr 2010, 21:55pm - WednesdayYesterday, I watch TV and shocked about the decision of the Judge (DOJ) that they release Ampatuan who brutally killed 57 people. Does the word "Justice" really work in our country? Well I guess this country is not an ideal one.
I am tired of the political issues in this country. The word CORRUPT is all over the country. There's no such news that no corrupted city. Such president, GMA, cover everything up. She's smart, yet too obvious. So far so good, she made the freedom fighters sent to prison.
In addition, such scheduled brown-outs. They say there's no water because El Niño. Do you really think its El Niño? If there's water, how can the water district supply water to us? As I remember, my last El Niño experience, even water supplies are scheduled for no water supply.
Straight to the point, scheduled brown-outs are for messing the incoming 2010 election since we are using electronic voting system. And messing our electric bill so that the politicians behind the power supplies need money from the people. Such sudden increase of electric bill price is an obvious move.
Well, there's nothing I can do about this country. This is how they make the Philippines go round. All I need is pray for my migration somewhere else and finally rest in peace.
One thing, here at my birth city, its starting to create a bad crowd. You know what I mean... :)
Whew! God help me go through that surrounds me... Please help me migrate away from this country.
I believe, this country would be next to Haiti neither of these countries; Afghanistan, Angola, Bangladesh, Benin, Bhutan, Burkina Faso, Burundi, Cambodia, Cape Verde, Central African Republic, Chad, Comoros, Democratic Republic of Congo, Djibouti, Equatorial Guinea, Eritrea, Ethiopia, Gambia, Guinea, Guinea-Bissau, Haiti, Kiribati, Laos, Lesotho, Liberia, Madagascar, Malawi, Maldives, Mali, Mauritania, Mozambique, Myanmar, Nepal, Niger, Rwanda, Samoa, São Tomé and Príncipe, Senegal, Sierra Leone, Solomon Islands, Somalia, Sudan, East Timor, Togo, Tuvalu, Uganda, Tanzania, Vanuatu, Yemen, Zambia...
No hay palabra de honor
Posted: 23 Jan 2010, 9:05am - SaturdayWhen I watched TV last December 2009 (which I watch TV rarely), I saw the advertisement of the promised politician, Manny Villar. (which also I got irritated with his ads) And I said, *puff!* He really got a guts running for President after his controversial C5. Not to mention what he promised to me and my colleagues way back year 2005, under Mindanao Business and Management Youth Congress program. (see picture below) And until now his ads still air on ABS-CBN. And thinking that every ads in ABS-CBN cost hundreds of thousands. Yet he can afford to air his ads. Then I realized the C5 controversial, and said to myself... Now I get it why he got enough funds for his campaign.
[caption id="attachment_337" align="aligncenter" width="540" caption="Manny Villar with MBMYC Staff"]
[/caption]
The picture was a meeting with Manny Villar and the MBMYC Staff. Villar promised that he will finance a livelihood program and helping the poor in the remote areas in Cagayan de Oro City. He made a lot of promises that day. Yet he accomplished nothing. After the meeting, no funds has been sent to us.
After that, I concluded that this politicians will do nothing for our country!
Election 2010, I won't vote any president! They are all the same! Dick, Binay, Noynoy and Villar... Same feathers! And they flock together!
Filipinos will always be hopeless with these kind of people!
In addition, I was tagged in the facebook and laugh hard about it... And I think its true! Bwuahahahaha!

:)
Visual C#: Retrieving Image (BLOB) from MySQL database
Posted: 14 Dec 2009, 15:48pm - MondayI've been searching an article about storing and retrieving an image (BLOB data type) from MySQL database. Somehow, I only found the retrieving process but I created the storing process using PHP... :)
You may download my works, link provided below...
- idsystem_database.sql.zip - the dump file of MySQL database; import this SQL file before running the project
- the rest of the files are the project sample files
MySqlConnection myConnection = new MySqlConnection(myConnString); string testQuery = "SELECT sp.studePhoto, s.firstName, s.lastName FROM students AS s, student_photos AS sp WHERE s.id = sp.studentID"; MySqlCommand myCommand = new MySqlCommand(testQuery, myConnection); myConnection.Open(); MySqlDataReader myReader = myCommand.ExecuteReader(); FileStream fs; // Writes the BLOB to a file (*.jpg). BinaryWriter bw; // Streams the BLOB to the FileStream object. int bufferSize = 100; // Size of the BLOB buffer. // The BLOB byte[] buffer to be filled by GetBytes. byte[] outbyte = new byte[bufferSize]; long retval; // The bytes returned from GetBytes. long startIndex = 0; // The starting position in the BLOB output. while (myReader.Read()) { DateTime tmp = new DateTime(); tmp = DateTime.Now; // Create a file to hold the output. string filename = camilordMD5(tmp.ToLongDateString().ToString() + tmp.ToLongTimeString().ToString()) + ".jpg"; string dest = Directory.GetCurrentDirectory() + "/" + filename; fs = new FileStream(dest, FileMode.OpenOrCreate, FileAccess.Write); bw = new BinaryWriter(fs); // Reset the starting byte for the new BLOB. startIndex = 0; // Read the bytes into outbyte[] and retain the number of bytes returned. //myReader.GetBytes(0, startIndex, outbyte, 0, bufferSize); retval =(long) myReader.GetBytes(0, startIndex, outbyte, 0, bufferSize); lblName.Text = myReader.GetString(1) + " " + myReader.GetString(2); // Continue reading and writing while there are bytes beyond the size of the buffer. while (retval == bufferSize) { bw.Write(outbyte); bw.Flush(); // Reposition the start index to the end of the last buffer and fill thebuffer. startIndex += bufferSize; retval = myReader.GetBytes(0, startIndex, outbyte, 0, bufferSize); } pictureBox1.ImageLocation = Directory.GetCurrentDirectory() + "/test.jpg"; //pictureBox1.Image = retval; // Write the remaining buffer. bw.Write(outbyte, 0, (int)retval - 1); bw.Flush(); // Close the output file. bw.Close(); fs.Close(); }
Facebook: Cafe World Tips and Tricks (Cheats)
Posted: 17 Oct 2009, 8:17am - SaturdayLately, I was addicted playing the Cafe World by Zynga. There are some tricks that my fellow office mates how to earn coins so fast and its cafe popularity. I would like to share this to you all...
[caption id="" align="aligncenter" width="580" caption="Deep freeze Popularity"]
[/caption]
Here's the Tips and Tricks...
[/caption]

- Barricade your chef and waiter(s) with tables (shown in the images)
- Remove your doors if you have nothing to serve, this is to preserve your popularity rate
- Serve at least 2 or more varieties of food to boost the growth of popularity rate
- Having below 15 popularity rate, If you notice that few customers are coming in, click the Expand Cafe or Functional then click the check or OK. This will make the customer appear in your restaurant automatically
- Having 30 popularity rate, put many doors as possible

Inter-Galactic Explorer
Posted: 28 May 2009, 0:15am - Thursday
- IF only U.S. , Russia and other major or rich country stop creating war but start researching how to expand our possibility to explore space, galaxy and universe
- IF only richest people do some advance research traveling space
- IF only stop using oil instead use energy
- IF only people stop the hunger of power and greediness
- IF only we concentrate to advance technology and health research
install and configure subversion (SVN)
Posted: 11 Jan 2011, 2:21am - TuesdayI keep this guidelines because I find it very useful which I think we need it in our project development as a team in Project CollabHQ. I'm getting tired synchronizing always my files in my local PC between published files after other team members updated the files in the server.
To install subversion on CentOS you need to have the RMForge custom repository enabled (read my "Add the RPMForge custom repository to CentOS" post about how to do this), and then issue the following command:
To install subversion on CentOS you need to have the RMForge custom repository enabled (read my "Add the RPMForge custom repository to CentOS" post about how to do this), and then issue the following command:
Unfortunately it doesn't set up anything else after installing the necessary files, so you need to add a subversion user and set up the repositories etc yourself. If we decide to call the subversion user "svn" then you add them like so:sudo yum install subversionThis will check for any dependencies and then prompt you to install those and subversion itself. Type in "y" and <enter> to install these.
sudo /usr/sbin/useradd svn sudo passwd svnAnd then change to the subversion user like so:
su svnChange to the svn user's directory and then create a "repositories" directory like so:
cd mkdir repositoriesAnd now create your project's repository. For example, if we had a project called "myproject" you would do this:
There will now be a "myproject" directory containing the following:cd repositories svnadmin create myproject
You need to edit "myproject/conf/svnserve.conf" and uncomment the following lines:-rw-rw-r-- 1 svn svn 229 Nov 21 16:58 README.txt drwxrwxr-x 2 svn svn 1024 Nov 21 16:58 conf drwxrwsr-x 6 svn svn 1024 Nov 21 16:58 db -r--r--r-- 1 svn svn 2 Nov 21 16:58 format drwxrwxr-x 2 svn svn 1024 Nov 21 16:58 hooks drwxrwxr-x 2 svn svn 1024 Nov 21 16:58 locks
and edit the password file "myproject/conf/passwd" adding a new user and password. Note that the password is stored in plain text. In the following example we have a user called "john" whose password is "foobar123":auth-access = write password-db = passwd
And finally, as the svn user, start the subversion daemon like so:[users] john = foobar123
You can now connect to the subversion repository at e.g. svn://svn@hostname/myproject You can add additional repositories under this user using the "svnadmin create" command and then access them at svn://[userame]@[hostname]/[project name] Other reference at http://wiki.centos.org/HowTos/Subversion Article by: http://www.electrictoolbox.com/install-subversion-centos/svnserve -d -r /home/svn/repositories
Link List
Posted: 2 Oct 2010, 12:56pm - SaturdayPast few weeks, been busy with my online jobs.. yet back to my study in C++, dev-C++. I'm having difficulty on understanding link list coz I'm in the mode of refuse to learn. However, forcing myself will achieve my goal. hehehehe..
Link below is the problem;
- Swapping a Link List elements
- Search and Delete an elements from Link List
VLSM Table
Posted: 31 Jul 2010, 21:19pm - SaturdayVariable Length Subnet Mask Table
Prefix | Add-on | Octet | Hosts | Subnet |
/30 | +4 | 4th byte | 2 | 255.255.255.252 |
/29 | +8 | 4th byte | 6 | 255.255.255.248 |
/28 | +16 | 4th byte | 14 | 255.255.255.240 |
/27 | +32 | 4th byte | 30 | 255.255.255.224 |
/26 | +64 | 4th byte | 62 | 255.255.255.192 |
/25 | +128 | 4th byte | 126 | 255.255.255.128 |
/24 | +1 | 3rd byte | 254 | 255.255.255.0 |
/23 | +2 | 3rd byte | 510 | 255.255.254.0 |
/22 | +4 | 3rd byte | 1022 | 255.255.252.0 |
/21 | +8 | 3rd byte | 2046 | 255.255.248.0 |
/20 | +16 | 3rd byte | 4094 | 255.255.240.0 |
/19 | +32 | 3rd byte | 8190 | 255.255.224.0 |
/18 | +64 | 3rd byte | 16382 | 255.255.192.0 |
/17 | +128 | 3rd byte | 32766 | 255.255.128.0 |
/16 | +1 | 2nd byte | 65534 | 255.255.0.0 |
… | … | … | … | … |
AB-220KC POS Printer Driver
Posted: 6 Jul 2010, 10:04am - TuesdayI'm having problem looking for this POS printer driver... its nowhere to be found in the internet... finally, you can download it here in my blog site...
Download Driver: V5R80-LEXS_AB-220KC-driver.zip
Product Details:
Type | Dot-matrix |
---|---|
Style | Black And White |
Use | receipt |
Interface Type | IEEE1284, RS232, USB |
Max Paper Size | 76MM |
Black Print Speed | 4.6LPS |
Brand Name | ZONERICH |
Model Number | AB-220KC |
Place of Origin | Guangdong, China (Mainland) |
URL | http://www.zonerich.com/english/ab-220k-c.htm |
Download Driver: V5R80-LEXS_AB-220KC-driver.zip
CEntOS: Securing FTP (vsftpd) and SSH
Posted: 8 May 2010, 23:13pm - SaturdaySECURING FTP
Use chroot_local_user=YES then the vsftpd.chroot_list becomes a list of users to NOT chroot. So... you said chroot ALL users but ftpuser.
Notice the commented out lines.
In /etc/vsftpd/vsftpd.conf:
chroot_local_user=YES chroot_list_enable=YES chroot_list_file=/etc/vsftpd.chroot_listedited /etc/vsftpd.chroot_list: add users only that DO NOT NOT NOT NOT get chrooted. use /sbin/nologin edited /etc/passwd entry for ftpuser:
ftpuser:X:#:#:FTP User Account:/home/ftpuser/./:/sbin/nologin------------
chroot_local_user=YES chroot_list_enable=YESmeans that by default ALL users get chrooted except users in the file
chroot_local_user=NO chroot_list_enable=YESmeans that by default ONLY users in the file get chrooted. See the difference? Article by: JordanH Final Configuration:
pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES chroot_local_user=YES chroot_list_enable=YES chroot_list_file=/etc/vsftpd/chroot_list pasv_enable=YES port_enable=NO pasv_min_port=60000 pasv_max_port=64000 # ftp settings connect_from_port_20=YES # User Settings pasv_promiscuous=YES dirlist_enable=YES download_enable=YESSECURING SSH Edit /etc/ssh/sshd_config and at the bottom of the file, add these lines...
# Allowed users to login SSH #AllowUsers root user002
# Disallow users in logging in at SSH #DenyUsers user001
Conspiracy Theory: Earthquake, Tidal Waves and other Natural Disaster
Posted: 3 Mar 2010, 10:44am - WednesdayDo you really think Earthquake, Tidal Waves and other Natural Disaster are really natural event? Like Haite Earthquake, Phuket Thailand Tsunami and Chile Earthquake...
For my analysis, these are man made events. It's a test causing Earthquake, Tidal Waves and other Natural Disaster. This is another mass destruction weapon of U.S. Government. It might be the HARP project nor other Top Secret project.
Yet, I don't know how to prove it cause I'm just a low life human being... :P
Visual C#: Detect Conflict Schedule
Posted: 18 Jan 2010, 16:55pm - Monday[caption id="attachment_329" align="alignright" width="271" caption="Screenshot"]
[/caption]
It seems a lot of people are searching about solving conflict schedule. So I decided to create a sample. Below is the core code of checking conflict schedule...

If you want to download the whole code, link below and enjoy... Do not practice the copy and paste! :) Download: detectScheduleConflict.zip// sample conflict detection (defined) [start] DateTime d = new DateTime(2010, 1, 13); richTextBox1.Text = DateTime.Now.ToLongDateString() + " = " + d.ToLongDateString() + "\n"; if (DateTime.Now.CompareTo(d) > 0) { richTextBox1.Text += "true\n" + DateTime.Now.CompareTo(d).ToString(); } else { richTextBox1.Text += "false\n" + DateTime.Now.CompareTo(d).ToString(); } richTextBox1.Text += "\n\n"; DateTime dx = DateTime.Now; //MessageBox.Show(dx.Hour.ToString()); DateTime[] dt = new DateTime[4]; // enrolled schedule dt[0] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 8, 0, 0); dt[1] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 9, 0, 0); // adding new schedule dt[2] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 9, 0, 0); dt[3] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 10, 0, 0); // checking schedule conflict if (((dt[0].CompareTo(dt[2]) < 0) && (dt[1].CompareTo(dt[2]) > 0)) || (dt[0].ToShortTimeString() == dt[2].ToShortTimeString())) { richTextBox1.Text += dt[0].ToShortTimeString() + " - " + dt[1].ToShortTimeString() + " against " + dt[2].ToShortTimeString() + " - " + dt[3].ToShortTimeString() + "\nResult: CONFLICT"; } else { richTextBox1.Text += dt[0].ToShortTimeString() + " - " + dt[1].ToShortTimeString() + " against " + dt[2].ToShortTimeString() + " - " + dt[3].ToShortTimeString() + "\nResult: NO CONFLICT"; } // sample conflict detection (defined) [end]
Visual C#: Handling X button (top-right)
Posted: 7 Dec 2009, 10:21am - Monday
private const int CP_NOCLOSE_BUTTON = 0x200; protected override CreateParams CreateParams { get { CreateParams myCp = base.CreateParams; myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON; return myCp; } }Add confirmation if window closing or closed... Insert this code to Main form or the Form1.cs...
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (MessageBox.Show("Are you sure you want to exit?", "Confirm exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { e.Cancel = true; } }Insert this to Form1.Designer.cs...
this.Closing += new System.ComponentModel.CancelEventHandler( this.frmCCS_Closing);
Gmail v.s. Ymail
Posted: 13 Jul 2009, 21:01pm - Monday
- Simple
- User-friendly
- Less Ads (if there's an ads, it's just a line)
- Powerful spam filter
- Lots of labs modules
- Sophisticated Functionalities
- Lots of spam
- Copied the chat functionality of Google
- Lots of Ads (like really big ads)
- Stupid Seals
Freelance Freedom by NC Winters
Posted: 20 May 2009, 17:51pm - WednesdayThese comic trips by N.C. Winters relates my work pretty much...