Author Archive

Dec
13

Biko Recipe

Posted by: | Comments (0)

This is a modified version of one of the most favorite Christmas noche buena dessert in the Philippines. The recipe is basically modified for those transplanted Filipinos whose only coconuts they can find comes in a can.

Ingredients:

  • 1 can coconut milk (400 ml)
  • 1/2 c water
  • 1 1/2 c brown sugar
  • 1 1/2 c sweet rice
  • evaporated milk (optional)

Procedure:

  1. Get the sweet rice cooking in a rice cooker.
  2. Mix the coconut milk, water, and brown sugar in a sauce pan.
  3. Heat the sauce pan with all the mixed ingredients until all the water has evaporated and it is caramelized. This is now called the “latik”. You have to keep stirring otherwise it will overflow and you’ll create a mess and your wife will kick you out of the kitchen. It will take a long time for the solution to become caramelized (latik), so you better not be doing something else. Now here’s the secret trick. To determine the proper consistency of the latik, take a glass of water from the faucet. Drop (just a single drop) of the solution you’re stirring into the glass of water. If you see that the “latik” settled to the bottom in whole (coagulated), then the latik is done and deserved to be called a “latik”.
  4. Mixed the cooked sweet rice and the latik in a bowl. You have to do this little by little to coat every grain of rice with the latik. What I do is take a little bit of rice, pour a little bit of latik, and mix them together very well. Put it aside in a baking pan, and repeat until you finish all the rice. Don’t worry if you end up with extra latik, you can also eat your biko, while drinking latik on the side.
  5. Once you have all the rice coated with the latik in a baking pan, you can optionally coat the top with some evaporated milk and bake it at 325 degrees for 15 minutes or until the milk forms a crust at the top.

There you have it. Enjoy your biko either with Coke or tea. Merry Christmas!

Categories : General, Notes
Comments (0)
Oct
29

Obtaining File Size

Posted by: | Comments (0)

The following snippet will determine the file size.


#include <iostream.h>
#include <fstream.h>

const char* filename = "example.txt";

int main() {
    long l, m;

    ifstream file(filename, ios::in|ios::binary);
    l = file.tellg();
    file.seekg(0, ios::end);
    m = file.tellg();
    file.close();

    cout << "size of " << filename;
    cout << " is " >> (m-1) << " bytes.\n";

    return 0;
}
Categories : Cpp, Notes
Comments (0)
Oct
29

Write To A Text File

Posted by: | Comments (0)

This snippet will write a text file.


#include <fstream.h>

int main() {
    ofstream outfile("example.txt");
    if (outfile.is_open()) {
        outfile << "This is a line.\n";
        outfile << "This is another line.\n";
        outfile.close();
    }
    return 0;
}
Categories : Cpp, Notes
Comments (0)
Oct
11

Quick Command Line Arg parsing

Posted by: | Comments (0)

To parse command line arguments passed to a script without using a module, parse @ARGV with the following:


foreach my $arg (@ARGV) {
    $a = 1, next if $arg eq '-a';
    $b = 1, next if $arg eq '-b';
    $c = 1, next if $arg eq '-c';
}

Note: This is good only for boolean (on/off) command line switches.

Categories : Notes, Perl
Comments (0)
Sep
24

Debugging CGI Using ptkdb

Posted by: | Comments (0)

ptkdb is a graphical Perl debugger. To use it when debugging command line scripts is very straight forward. Just type in the command line:


perl -d:ptkdb script.pl

and you’re good to go.

However, using it to debug CGIs needs some tweaking to your CGI source. Replace the usual

#!/usr/bin/perl

line at the top of the CGI script with this one:


#!/usr/bin/perl -d:ptkdb
BEGIN {$ENV{DISPLAY} = "$ENV{REMOTE_ADDR}:0.0";}

Go to your browser and invoke your CGI and a debugger window should pop up.

Categories : Notes, Perl
Comments (0)
Sep
10

Change Behavior of iTunes Arrows

Posted by: | Comments (0)

Starting with iTunes 4.5, Apple implemented those little grey arrows next to the song title, artist, and album, which will take you to the corresponding match in the iTunes Music Store. To change the behavior of these arrows so that instead of going to the store, it will take you to your library instead, you can do either one of two ways:

  1. Hit option key when you click the arrow.
  2. Change it permamnently by executing this from the terminal:
    defaults write com.apple.iTunes invertStoreLinks -bool YES

    Make sure iTunes is not running when you execute this command.

Categories : Mac OS X, Notes
Comments (0)
Sep
08

Enable Safari Debug Menu

Posted by: | Comments (0)

To enable Safari Debug menu from the command line:

% defaults write \
com.apple.Safari IncludeDebugMenu 1

Make sure Safari is not running when you run this command.

Categories : Mac OS X, Notes
Comments (0)
Sep
07

Determine Disk Usage

Posted by: | Comments (0)

This command will show the number of KBs used for all non-hidden files and folders in the current directory:

du -sk * | sort -rn
Categories : Linux, Notes
Comments (0)
Aug
11

Find By Contents

Posted by: | Comments (0)

This will recursively search all the files, with a certain filename pattern (in this case *.h) in a certain directory, that contains a certain text pattern in its contents (in this case ‘DeviceDriver’).

find . -name '*.h' -print0 \
| xargs -0 grep -n -e DeviceDriver
Categories : Linux, Notes
Comments (0)
Aug
02

CGI To Display Module Documentation

Posted by: | Comments (0)

Here’s a CGI to display a module’s POD. The module has to be in the $INC. This is great for providing documentation to internal modules.


# save this as showdoc.cgi
#!/usr/local/bin/perl
use strict;

use Pod::Html;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

# Send out the header
print "Content-type: text/html", "\n\n";

my $q = new CGI;

my $module = $q->param('module');
require $module;

$| = 1;

chdir ("/tmp");

my $fullpath = $INC{$module}
    or die "$module not found";

pod2html("--infile=$fullpath", "--flush");

# Clean up the junk left by pod2html
END {
        unlink("pod2html-dircache");
        unlink("pod2html-itemcache");
}

To use this, say you want to view POD for Data::Dumper:



http://localhost/cgi-bin/showdoc.cgi?module=Data/Dumper.pm

Categories : Notes, Perl
Comments (0)