Sunday, April 14, 2013

Self Signed SSL Certificates

Ever wondered how to enable SSL or HTTPS on your site? If you dont want to pay for commercial SSL certificates, you could create self signed certificates for your site by following the instructions here:

The instructions in the site above will make your default site HTTPS enabled. If you prefer having a commercial SSL, save your certificate files and key files in your server and edit the location on the /etc/apache2/sites-enabled/default to point to the directory where you stored those files.

Sunday, December 2, 2012


In line with the nationwide Sanitation Hackathon organized by several organizations here in the philippines and abroad, I mentored for one of the GDG chapters here in Davao.

After my presentation yesterday, I myself attempted to do a quick hack on how to help in the sanitation problems faced here and abroad.

Using Google Maps Javascript API and a supposedly a little bit of PHP (but I became to busy to continue the rest of the application) I've created a webapp which does a simple basic thing: get your current location and report/tag it as an offender. This is in hoping that the corresponding establishments and local government units to improve the sanitation of their provided restroom facilities.

Unfortunately, since im one of the mentors for the Davao participants, I wont be able to join the submission of entries. Its a nice proof of concept though :) 

The source code could be viewed (since its all just a bunch of HTML and JavaScript. The app is available at 

Friday, September 21, 2012

LTE and the Unlocked iPhone 5

So heres the deal, theres a new iPhone out there and its got the new blazing LTE. If you're planning to get one buying from countries which have unlocked options (Canada, Singapore, Hong Kong) doesnt necessarily merit that you'll get LTE compatibility wherever you go.

In the iPhone 5 website, theres a little asterisk there. Pretty sneaky if you ask me, that they have created 2 different models probably using 2 different LTE chips.

GSM model A1428*: UMTS/HSPA+/DC-HSDPA (850, 900, 1900, 2100 MHz); GSM/EDGE (850, 900, 1800, 1900 MHz); LTE (Bands 4 and 17) 
GSM model A1429*: UMTS/HSPA+/DC-HSDPA (850, 900, 1900, 2100 MHz); GSM/EDGE (850, 900, 1800, 1900 MHz); LTE (Bands 1, 3, 5)
- From:

So what does this mean? If you're planning to get an unlocked unit from other country, LTE speeds might not be compatible with yours. From Wikpedia, theres a working list of LTE bands per country.

With me residing in the Philippines it seems that the LTE band in the Philippines is LTE Band 1 and 3 (GSM model A1429). But what if im travelling outside? US or Canada perhaps? I think what better way to explain this by plotting it into a spreadsheet.

So, how do you look at the graph? Normally, you would be sourcing your phone from somehere its factory unlocked. Either Hong Kong, Singapore, Canada (or US once they make it available in the Apple Store) So, look for the country where your unlocked iPhone will be originating. Most likely that the iPhone that will be sold there will be using that LTE band (duh). After, look for the country you will be using your phone. For me, I will be looking at the Philippines.

From here, it seems like the Philippines is using LTE band 1 and 3 (A1429) and the countries which will most likely sell an unlocked A1429 would be: Singapore, Hong Kong, Australia.

If you would notice, if I buy myself an A1429.. LTE features might not work when I fly to either Canada or the US. Sad.

Anyway, as a disclaimer, this spreadsheet was compiled September 2012 and may not reflect the changes once new carriers roll out new LTE infrastructure in the future.

Saturday, September 15, 2012

Comparing Prepaid Data Plans from Globe, Smart and Sun

Recently I have been thinking about those minor differences when it comes to subscribing to a data plan here in the country. So far we're fortunate that we have lots of options but apparently, it takes some discerning as to what to subscribe to given the situation.

I have been in several instances wherein, I was at the beach with friends for 3 days. I would be getting a better deal if I subscribed into an unlimited data for 3 days rather than 1 day and resubscribe every time. Thinking about my consumption, since I didnt bring my laptop then (hey, it was Boracay!) the only thing I do with my iPhone was to check my mail and check in to 4square. Maybe an MB based subscription might be better.

On a recent trip, I was on the road going to the beach (again) but this time I have with me my laptop with the intention of squeezing in some work during the long travel time. I opted to subscribe for a 1 day unlimited since I knew for a fact that I would't be working on the way back.

So upon rummaging through the websites of our favorite telcos, I sorted the mobile dataplan for each. One is for MB based (currently sorted by the allocated MB) you may also cross reference it for the cost/MB ratio if you're getting a good deal.

Another, comparing the unlimited data plans. I sorted them according to the number of days you would be needing to be online. Again I also provided a column for cost/day ratio which you could try to pick if its just right for you.

Take note that these plans are for PREPAID sims only. I also did not include the hourly plan of Sun which doesnt really coincide with the MB chart.

Wednesday, June 13, 2012

Data Disaster

Several years ago, I was issued a white Macbook for work which I typically use for everything. I have my work files there, I have my personal files there and it has been part of my life. A colleague who was issued the same Macbook model woke up with an error with his Mac hard drive. 
Photo credit from here
As part of my work, I tried to recover whatever is recoverable in his drive. We had a Network Access Storage (NAS) which is seldom used but most of his files are in his Mac hard drive. Tough luck, after doing whatever I can to recover, I declared it dead. It was lucky that it was still under warranty but the files lost, or the time devoted to writing those files or creating those files will never be replaced. 

Soon enough, despite that warning, mine gave out. Died. Same error. Despite that earlier warning, I didnt back up either to the NAS or to any other storage. If felt like my life has been wiped clean. Source codes, documents, pictures, my life. Its hard to accept losing something that you've taken time to collect. Those pictures, that vacation, that exact moment, those kilo lines of code you wrote. Gone. 

I picked up whats left from fragments of my life scattered around. Some work files are in the NAS, some were in Google Docs, some in my old desktop PC, some in my laptop which was with my sister in Canada. As for the pictures, I had to pay Multiply to bulk download all my pictures in high res. I had to pay for my pictures. I kinda felt raped. Multiply was never fair to those people taking away data (see this post)

I bounced back after some time, I just thought to myself, any file that I wouldnt be looking for isnt probably needed anymore. After several years and several iterations of hardware, I found myself having too much spare hard drives either being given to me by my uncle as spare parts or part of my old PC. Old stuff, 40GB, 80GB, 120GB, 250GB IDE drives. Not much use slapped inside a PC. 

Lining them up to be loaded and labelled
It took some time for me to sort out everything in my digital life. In general, I have sorted into folders like: Pictures, Downloads, Documents, Music, Pogz Files (source codes and anything that doesnt fit anywhere else) and figured out that most of the folders, when organized properly are relatively small. Chunks of 10GB, 27GB and the largest are like 78GB, 40GB. Then I realized that maybe I could do a quarterly backup using my old drives. Its like a puzzle making combinations of folders fit in drives which had limited capacity. I end up with several drives and most of my folders backed up in 2 drives. I cant gamble the reliability of those old drives so having a secondary or tertiary backup would be great (since I have a lot of drives anyway). 

Yesterday, my netbook just gave up on me. Again, most of my files are there but thankfully, a part of the partition is still intact. I've been backing up since last night to my drives and would send the laptop to HP to claim its rightful warranty. 

My IDE poormans drive backup didnt save me this time, but it felt assuring that I do have some backups (even if its months back) rather than starting my life from scratch. 

To those who might ask: Why not buy dedicated cloud storage for backup? Dropbox? Google Drive? Amazon S3 + ZManda? 

To tell you the truth, I have considered that option. It would be a whole lot cheaper and more reliable than what I do, or compared to buying NAS drives or portable hard drives. But the problem is, despite my downstream hitting around 2Mbps, my upstream is a measly 512Kbps. The total filesize of all my folders is around 170gb. I have files which also exceeds upload limits. 

Then again, being partially safe, is better than not being safe. 

Sunday, October 2, 2011

[Programming] XMPP and Office Guru (Part 2)

Since my last post, I had a really hard time making XMPP work using XMPP severs for Linux. Luckily, there was an easier way of doing things without the messy details of installing and hosting your own XMPP server. From this post, How to Write Your Own IM Bot in Less Than 5 Minutes ( I found out that there is a service called IMified which 'hosts' your bots and calls a specific page to do all the processing. As an overview, below is a simple diagram on how IMified works.

So going back to our previous problem, how do we create a location monitoring application which accepts user input thru IM and then displays it to a screen? So with my IMified bot in place, what I did was to code a simple PHP page which accepts POST parameters from IMified and processes it accordingly. Below is the source code for the page which accepts the values sent from IMified

IMified Message Handler
Allan Paul "Pogz" Sy Ortile
June 2011

IMified sends information through POST requests 
which in turn is then handled by this page.
For the complete list of POST values sent, you
may consult
for more details. 

$user = $_POST['user'];
$msg = $_POST['msg'];
// Time stamp to log what time the message was recieved
$time = time();

// Connect to database
$con = mysql_connect("host","username","password");
if (!$con)
	die('Could not connect: ' . mysql_error());
	// Select the database to use
	mysql_select_db("db_name", $con);

	// Ass the message to the table in the database	
	mysql_query("UPDATE tbl_user SET time = '$time', location = '$msg' WHERE ymuser = '$user' ");

	// Bot reply to user
	echo "Hi " . $user . "! Your current location has been logged! ";


If we would trace what is happening between the user, the IMified service and the webserver you may refer to the steps below:

1.) ymuser sends "currently at the office" to the ymchatbot hosted by IMified
2.) IMified processes the message and then passes the POST values to the page located in our webserver
$_POST['user']; now contains the value ymuser
$_POST['msg']; now contains "currently at the office"
3.) The accepting page now processes the POST values sent which is then saved to a database along with a timestamp generated from the PHP code.
4.) The accepting page replies with "Hi ymuser! Your current location has been logged!"

So now, the values are saved into our MySQL database which is then picked up by another page which is just a regular PHP page. The source code could be found below:

Location Output Page
Allan Paul "Pogz" Sy Ortile
June 2011

// Connect to database
$con = mysql_connect("host","username","password");
if (!$con)
	die('Could not connect: ' . mysql_error());
	// Use database and table
	mysql_select_db("db_name", $con);

	// Do query and pick only the ones in the SMS team and order it by latest timestamp
	$result = mysql_query("SELECT * FROM tbl_user WHERE team = 'SMS' ORDER BY time DESC ");
	// Display unique recent post
	echo "<body bgcolor='#FFFFEE'>
	<div align='center'>
	<table border='1'>
	<th align='center'><b><font size='+2' 'verdana'>USERNAME</b></font></th>
	<th width='250' align='center' ><b><font size='+2' 'verdana'>TIME</b></font></th>
	<th width='550'><b><font size='+2' 'verdana'>LOCATION</b></font></th>
	// Some output mumbojumbo
	while($row = mysql_fetch_array($result))
	$human_time = date('d-m-y H:i',$row['time']);
	echo "<tr>";
	echo "<td align='center'><font size='+2' face='verdana'>" . $row['dlsuuser'] . "</font></td>";
	echo "<td align='center'><font size='+1' face='verdana'><b>" . $human_time . "</b></font></td>";
	echo "<td><font size='+2' face='verdana'>" . $row['location'] . "</font></td>";	
	echo "</tr>";
	echo "</table>



The database schema contains the following fields: uid, ymuser, dlsuuser, time, location, team. All of which are text values save for uid and time which are integer values. So, you might be wondering why I opted having a ymuser field and a dlsuuser field. The two fields just does a mapping of the persons YM id with its corresponding work userid. Its just for formalization.

From our infrastructure monitoring screen, I just added an iframe which just calls the page where the results are displayed.

Its pretty much straight forward.

Posting Source Codes

I have a draft post to the part 2 of my previous post about creating a chatbot, it seems like it has been stuck in draft for quite some time since I was looking for a solution on how to post source code here in Blogger. After trying out some stuff and having failed attempts, I went out for a while and shelved the whole thing.

<? PHP
echo ("Hello World!");

Credit goes out to which apparently, I've failed to see previously.

After trying it out, I've seen a  more proper and elegant solution. By enabling the "Show HTML literally" and adding a <pre> </pre> tag on the HTML source of the post one could obtain the formatting above. Hopefully I could finalize my previous post about setting up a chatbot.