Tanjoubi omedetou

Posted by Lloyd on November 27, 2011 at 3:42 am

age++;

From coding to capturing moments

Posted by Lloyd on November 19, 2011 at 11:41 am

Since the day I started with my career I’ve been so busy, in fact, there’s nothing else to do but work. It’s been the same old routine but because I love what I’m doing, it’s not something to complain about. Not long ago, I wished to do something else, something I haven’t tried and was hoping to fill the empty spaces of my life.. and so my interest in photography started. It was a no brainer choice because it feels close to what I’m doing everyday except I won’t be dealing with codes but pictures. I knew it was not going to be easy because it never was, it needs judgment and skill. I don’t have a good judgment and skill. I’m just some guy entering a new realm with a vast universe of people who have spent their entire lives doing it. But, it’s not a problem. I’m here to learn. This year I was able to travel in different places and do things I haven’t done before – I was able to get away from the city limits. It’s also one of the reasons why I’ve been busy.

I spent majority of my free time tinkering with my camera and traveling with friends who share the same interest. It was a tiring new hobby and is expensive, too. We went to places around the country where people don’t normally go to just to explore and take the time to experiment with our skills. I can count the places we’ve visited but I’ve already lost count how many times I tried to make a good photo and most of them are failures. Despite not being in the level of the experts, I still have the spirit that one day I will be good enough. But for now, I’ll carry my patience with me and learn as we go along.

View some of my photos on flickr and 500px.

Not busy?

Posted by Lloyd on November 19, 2011 at 10:18 am

It’s surprising how I only have few tabs opened during weekends compared on weekdays where I have more than a dozen and more than 2 windows opened. It’s also surprising that I’m taking the time to write about it, too.

Quick update 2

Posted by Lloyd on August 24, 2011 at 5:49 pm

The guy who owns this site is busy and lazy to post. He just logged in today and updated WordPress to the latest version. That’s all.

Adobe Flash player update installation 2

Posted by Lloyd on April 02, 2011 at 9:04 pm

I always notice things, even unimportant ones. Today, I noticed Adobe’s flash update installer. When updating a software you usually see the word Install once and after that you only need to press Next and Done. For Adobe, showing the Install button once is not enough, they show it twice. It’s not a problem really, but I’m guessing or probably the first Install button should indicate a Download button because clicking it doesn’t install the update, it downloads it and then installation happens. I took some screenshots of the update process and it shows that I may be correct with my guess.

First one says install:

The next one which happens after clicking the “Install” button is actually a download:

Next one, there is another “Install” button, this time it’s the real one:

Last one, installation is completed:

See what I’m saying?

Windstruck 1

Posted by Lloyd on March 27, 2011 at 10:06 am

It’s probably the saddest movie I’ve ever watched. It’s so sad I had a teary eye, I really felt it. Srsly. It’s korean and it’s good. There are funny parts at the beginning but through out the movie it’s all sad. Get yourself a good sad movie, I recommend it. After watching, this song should remind you of the movie.

Watch the movie and then watch this another movie as they have some connections.

PHP session not persistent after server migration

Posted by Lloyd on March 27, 2011 at 8:52 am

Nerd Talk

I remember when we setup an Apache web server to move from Lighttpd, after we installed PHP we just copied over the same php.ini file to use the same settings. During testing I had a problem with sessions not persisting between pages, it was a pain to realize the problem at first. The cause of the issue is with the session.save_path, since we just copied over the old php.ini file, the folder path set to where the session should be saved is, well, not existing. I created the folder, the session folder, set write permissions and sessions are flying across pages!
You can find the session.save_path directive in /etc/php.ini and check out where sessions are saved, ex:

session.save_path = "/var/lib/php/session"

I believe it’s not the best practice to set 0777 (means everyone can read/write) permissions for the sessions folder as other users of the server may be able to hijack session files so be careful on this.

Literally, this is the song that played on my head when things started to work. It’s one of my childhood anime song. Watch and listen to this!

I’m eating bacon and rice for breakfast right now, btw. Just saying ;p

Debugging lighttpd’s 404 handler

Posted by Lloyd on March 19, 2011 at 4:38 am

Nerd Talk

I recently fixed an issue in the server that’s related to lighttpd 404 handler. The problem is when a URL is accessed with weird characters lighttpd returns a 404 page. For example, you saw something like this in your page views log and it returned a 404 error:

http://agyuku.net/%C2%A0

The example above results to “http://agyuku.net ” in the browser and returns Page Not Found. Notice the space after .net. The weird character “%C2%A0” is translated by the browser as a space but the server actually sees it as something else. Adding a space after the domain doesn’t really cause the server to react and treat it as a missing page. A solution that should do the work is to add a rewrite rule in lighttpd’s conf file:

"(.+?)(%C2%A0)$" => "$1"

The regular expression matches the weird characters at the end of the URL. When lighttpd receives a page request it will only read the URL without the weird stuff. $1 is a back reference to the regular expression pattern which means use those that matches the first pattern, in this case it’s (.+?). This should actually work but there’s a case due to different server settings, this may not solve the issue as lighttpd doesn’t see “%C2%A0″ as-is when the URL is accessed, it may be something else.

If the above method didn’t work then enabling lighttpd’s debug variables will give a clue to the issue. The debug variables are disabled by default, somewhere in lighttpd.conf set these to be enabled:

debug.log-request-header   = "enable"
debug.log-response-header  = "enable"
debug.log-request-handling = "enable"
debug.log-file-not-found   = "enable"

Once those are set save lighttpd.conf and restart the server. Access the URL with weird characters in the browser to trigger the error and it should write something in the server’s error log. Do a tail to the error log to check the last reported error:

tail -n 150 /path/to/your/error.log

The command above displays the last 150 lines in the error log. Check the displayed errors and there should be something like:

(response.c.221) -- splitting Request-URI
(response.c.222) Request-URI  :  /%C2%A0
(response.c.223) URI-scheme   :  http
(response.c.224) URI-authority:  agyuku.net
(response.c.225) URI-path     :  /%C2%A0
(response.c.226) URI-query    :
(response.c.254) -- sanatising URI
(response.c.255) URI-path     :  /Â
(mod_access.c.135) -- mod_access_uri_handler called
(response.c.391) -- before doc_root
(response.c.392) Doc-Root     : /some/document/root/path
(response.c.393) Rel-Path     : /Â
(response.c.394) Path         :
(response.c.442) -- after doc_root
(response.c.443) Doc-Root     : /some/document/root/path
(response.c.444) Rel-Path     : /Â
(response.c.445) Path         : /some/document/root/path/Â
(response.c.462) -- logical -> physical
(response.c.463) Doc-Root     : /some/document/root/path
(response.c.464) Rel-Path     : /Â
(response.c.465) Path         : /some/document/root/path/Â
(response.c.482) -- handling physical path
(response.c.483) Path         : /some/document/root/path/Â
(response.c.539) -- file not found
(response.c.540) Path         : /some/document/root/path/Â

Notice /%C2%A0 translated as . The browser converts the weird characters as a space but the server treated it differently and converted it to “”. A 404 response is sent by the server because it’s trying to find /some/document/root/path/ which doesn’t exist. We will use the findings above to fix the issue, modify the URL rewrite to something like:

"(.+?)(%C2%A0|Â)$" => "$1"

The pattern now includes the weird character in the URL (just to be sure we handle it as well) and the one that the server see internally (the “”). Save lighttpd and restart the server. Access the URL and it should load up the page without an error.

The above scenario is something I experienced and may be different from issues you may have but I hope it helps someone. And wow, it’s 4 in the morning, I should get some sleep.

More on lighttpd debug variables here.
I used http://agyuku.net an example domain only and it’s not running in lighttpd, it runs in Apache.

Exclude svn folder when copying files to another location

Posted by Lloyd on March 19, 2011 at 3:11 am

Quick Tip

Copy files from an SVN folder to another location and excludes all .svn folders. This copies files from the source to destination recursively, -r.

rsync -r --exclude=.svn /path/to/source /path/to/destination

More about rsync here.

Added to wishlist 2

Posted by Lloyd on February 19, 2011 at 8:27 pm

Apart from wanting to buy a Nintendo 3DS, I also want to buy a DSLR – Nikon D3100. I’m hoping to buy either one of the two this year.

And for today, a random image of Lucy going nuts! xD

Image of the day 1

Posted by Lloyd on January 08, 2011 at 9:15 am

Anime time!

I don’t have any new animes to watch lately so I’m re-watching one of my favorites, Fullmetal Alchemist Brotherhood! There are really a lot of funny moments all through out series which is why I don’t mind watching it again. Today, I find this one particularly funny when Ed was asking Al and Winry why Al got rejected to be Winry’s wife, Winry said “I don’t want a man shorter than myself” which kinda lead to this picture of them XD

Ed and Al always had a talk during their childhood about who would take Winry as a wife.

Freeze! 1

Posted by Lloyd on January 08, 2011 at 8:30 am

This happened last night while at the office waiting for some uploads to finish I was playing around with my Ubuntu (11.04) box when I got this CRAZY art using Firefox. I remember the old days when I used to get this all the time when using IE6.

New year folks!

Posted by Lloyd on January 02, 2011 at 6:53 am

Alrighty, it’s a brand new year so I guess I have to put in a post. I actually wanted to post yesterday, first day of the year, but..I was kinda busy doing stuff like eating, reading on StackOverflow, watching animes and K-Pop. Been messing with Ubuntu as well (using a virtual box) so I haven’t really planned anything yet, however, no promises but I will try to post more this year ;)

Happy new year to you, dear readers! I know my visitors are mostly robots and spiders, though. And also, watch this if you’re not a robot or a spider :)

array_count_values for float values 1

Posted by Lloyd on December 11, 2010 at 2:04 pm

Nerd Talk

array_count_values function in PHP can only count integer and string values. At some point you may need to count occurrences of float values in an array but you can’t because array_count_values won’t let you. If you have an array like:

$digits = array(14.5, 5.42, 1.5, 8, 14.5);
$digits = array_count_values($digits);

This will give you a warning that says, Warning: array_count_values() [function.array-count-values]: Can only count STRING and INTEGER values!

There’s actually a hack to get around this and achieve counting occurrences of float values. All you need to do is cast all float values in the array as string. array_count_values can also count integers so why not just cast the values as int? You don’t want to do that because casting the float values as int will change the data type to int but also remove the decimal points in your values and make it a whole number. Take this as an example:

$float = 12.8;
var_dump($float);         // float(12.8) - original float value
var_dump((int)$float);    // int(12) - becomes whole number
var_dump(intval($float)); // int(12) - becomes whole number
var_dump((string)$float); // string(4) "12.8" - string type

Based on the example above we need to cast the float values as string. So in the case of the array that we want to count the values, we need to do something like:

$digits = array(14.5, 5.42, 1.5, 8, 14.5);
$newDigits = array();
foreach($digits as $key => $value)
	// cast float as string
	if(is_float($value))
		$newDigits[$key] = (string)$value;
	// for actual int and string values
	else
		$newDigits[$key] = $value;
 
$countValues = array_count_values($newDigits);
print_r($countValues);

The above code will cast all float values in the array as string and array_count_values will work as expected. The output will be:

Array
(
    [14.5] => 2
    [5.42] => 1
    [1.5] => 1
    [8] => 1
)

Hope that helps!

age++;

Posted by Lloyd on November 27, 2010 at 12:23 am

yep, just like all incremental variables in programming our age does increment. This time it’s my age’s turn to add up. It’s been a crazy whole year since my last birthday, nothing has changed I’m still me, I’m still busy but I like it. Looking forward for another exciting and challenging year! +100 points to God! ^_^


^ Back to Top