There's a shortcut for creating a pf rule that applies to both IPv4 and IPv6. E.g.:
pass in quick on em0 from { 192.168.86.0/24, 2001:418:c0de:babe::/64 } to any keep state label "experimentation"
Results in:
root@soulfury:~# pfctl -sr | grep experimentation
pass in quick on em0 inet from 192.168.86.0/24 to any flags S/SA keep state label "experimentation"
pass in quick on em0 inet6 from 2001:418:c0de:babe::/64 to any flags S/SA keep state label "experimentation"
Tuesday, November 25, 2008
Monday, November 24, 2008
Hello world from links
I forgot to bring my MacBook, so I'm now surfing the Net in a text-only browser inside a server. I'm surprised that Blogger works. Very cool.
Saturday, November 22, 2008
Acer 4330 Driver Installation
I'm continuing the setup for my Acer 4330 laptop. I gave up installing Windows XP because I don't have the time to hunt down the correct drivers. I've installed Windows Vista instead.
I'm annoyed with Vista's UI. Fortunately, I won't have to use this because I'll give this to my parents. Sorry mom and dad, I really don't have time to install XP. This is the best I can do.
The DVD provided with the laptop contains multiple drivers. I think Acer doesn't use a standard hardware for all of its laptops. I think they just choose the cheapest hardware available at the time of production.
Anyway, here are the drivers that worked for me:
Chipset - Intel Chipset
VGA - Intel VGA driver
Audio - Realtek (No need to install; it works after installing Vista. Install this if you want the volume buttons to work.)
Modem - Foxconn, probably, but I didn't install it
LAN - Realtek
TouchPad - ALPS Touchpad
Card Reader - I don't know; there was no need to install it.
Camera - There are 3 drivers (Suyin, Bison, and Chicony), but I didn't bother installing any of them. Please leave a comment if you know the correct one.
WLAN - Atheros
BlueTooth - the only driver, Foxconn, doesn't seem to work. I'm not sure if there's really a built-in Bluetooth in this laptop. There's a Bluetooth button, but this may have been reserved for other models.
I'm annoyed with Vista's UI. Fortunately, I won't have to use this because I'll give this to my parents. Sorry mom and dad, I really don't have time to install XP. This is the best I can do.
The DVD provided with the laptop contains multiple drivers. I think Acer doesn't use a standard hardware for all of its laptops. I think they just choose the cheapest hardware available at the time of production.
Anyway, here are the drivers that worked for me:
Chipset - Intel Chipset
VGA - Intel VGA driver
Audio - Realtek (No need to install; it works after installing Vista. Install this if you want the volume buttons to work.)
Modem - Foxconn, probably, but I didn't install it
LAN - Realtek
TouchPad - ALPS Touchpad
Card Reader - I don't know; there was no need to install it.
Camera - There are 3 drivers (Suyin, Bison, and Chicony), but I didn't bother installing any of them. Please leave a comment if you know the correct one.
WLAN - Atheros
BlueTooth - the only driver, Foxconn, doesn't seem to work. I'm not sure if there's really a built-in Bluetooth in this laptop. There's a Bluetooth button, but this may have been reserved for other models.
Friday, November 14, 2008
HOWTO Turn off DHCP Servers in VMware Linux
To turn off VMware's DHCP server in host-only network, simply find the appropriate DHCP process, and kill it:
root@soulfury:~# ps auxww | grep dhcp
root 5060 0.0 0.0 1892 252 ? Ss Nov10 0:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware/vmnet8/dhcpd/dhcpd.conf -lf /etc/vmware/vmnet8/dhcpd/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet8.pid vmnet8
root 5061 0.0 0.0 1888 520 ? Ss Nov10 0:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware/vmnet1/dhcpd/dhcpd.conf -lf /etc/vmware/vmnet1/dhcpd/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet1.pid vmnet1
root 21281 0.0 0.0 2796 748 pts/0 R+ 15:31 0:00 grep dhcp
root@soulfury:~# kill 5061
root@soulfury:~# ps auxww | grep dhcp
root 5060 0.0 0.0 1892 252 ? Ss Nov10 0:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware/vmnet8/dhcpd/dhcpd.conf -lf /etc/vmware/vmnet8/dhcpd/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet8.pid vmnet8
root 5061 0.0 0.0 1888 520 ? Ss Nov10 0:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware/vmnet1/dhcpd/dhcpd.conf -lf /etc/vmware/vmnet1/dhcpd/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet1.pid vmnet1
root 21281 0.0 0.0 2796 748 pts/0 R+ 15:31 0:00 grep dhcp
root@soulfury:~# kill 5061
Thursday, November 13, 2008
FreeBSD Problem: Can't see files/dirty state at each boot.
Weird problem. The filesystem is in an unclean state at each boot, even though I have ran fsck before booting the system. Initially, our problem is that our app can't "see" certain files at first read, although subsequent attempts on reading them are OK. Later, we discovered that the filesystem is dirty at each boot. The problem is similar to this issue in FreeBSD-CURRENT. We're using FreeBSD 7.0-RELEASE though, so I'm not sure if we have the same problem. I need to track this down.
Tuesday, November 04, 2008
PHP doesn't support dot characters in form names
I've written a PHP proxy script that communicates with an underlying application. I encountered a problem where the script is unable to proxy data that contains dot characters in the form name.
To illustrate:
Solution
I accessed the raw input stream directly instead of using $_POST:
To illustrate:
<?phpOutput:
var_dump($_POST);
?>
<form action="test.php" method="post">
<input name="this.is.a/variable" type="text" />
<input type="submit" />
</form>
array(1) {
["this_is_a/variable"]=>
string(0) ""
}Notice the array key in the var_dump(); dots are converted into underscore.Solution
I accessed the raw input stream directly instead of using $_POST:
<?php
$data = file_get_contents("php://input");
$response = proxy_blah_blah($data);
?>
Tuesday, October 28, 2008
HOWTO Install Windows XP on Acer 4330
I bought an Acer Aspire 4330 a few days ago, but I couldn't install Windows XP. I think it's designed for Vista, but I don't want to use it because it's unusable. Windows XP Setup coredumped after a minutes, and I thought I had to slipstream the installation CD to solve this. Fortunately, a friend told me that all I had to do was to change my SATA mode from AHCI to IDE. The setup then went smoothly.
Installing the drivers is a PITA. The drivers in the provided DVD doesn't work because they're for Vista. I had to download the files from their FTP site.
Unfortunately, they provide multiple drivers for the same device. Do I need to use the driver for Atheros? Or Broadcom? Or Intel? Blah.
I'll continue installing the drivers tomorrow. I still have to finish this router/load balancer that I'm making. Hopefully, our connection would become twice as fast after we combine Bayantel and Globe connections. More on this later.
Monday, October 27, 2008
PHP's New Namespace Separator
I don't like PHP's new namespace separator. I prefer '::' to '\'.
Aaaaargh... why did they choose the escape character?
Aaaaargh... why did they choose the escape character?
Slow lighttpd using IPv6
I've been wondering why lighttpd seems to be so slow when IPv6 is enabled. I discovered that I had to bump the minimum and maximum number of FastCGI process (min-procs/max-procs) by twice as much because it appears that lighttpd divides the available PHP processes between IPv4 and IPv6. I dunno why it does that.
Thursday, October 16, 2008
How to destroy all gif interfaces in FreeBSD
To destroy all gif interfaces in FreeBSD (vanilla Bourne shell):
for i in `ifconfig -a | grep gif | grep -v '%' | sed -n -e 's/\(.*\):.*/\1/p'`; do
ifconfig $i destroy
done
Monday, October 13, 2008
Stuck DVD inside MacBook
A DVD got stuck inside my MacBook. What I did was to insert a prepaid card (it's made of plastic that's thin yet durable enough for this purpose) into the DVD slot, pushed it upwards and pressed the eject button. The DVD then came out.
Thursday, October 09, 2008
Looking for a used PC
I'm looking for a used Pentium III (or better) PC that I can use as a router/firewall. No need for monitor, keyboard, or CD-ROM. Just a CPU with enough hard disk and RAM. Please contact me if you have one. Cebu area only.
Wednesday, October 01, 2008
Library dependency woes
One of my Unix workstation is now fucked up due to forced installation of incompatible libraries. I guess I'll have to reformat it in order to start from a clean slate. I'm planning to temporarily transfer my files to my external harddisk, but FreeBSD can't seem to read it although it has been formatted as UFS. I formatted that harddisk on my Mac OS X laptop, thinking that it can be read in FreeBSD, but Mac OS X seems to have a different interpretation of what UFS is. Blah. I guess I need to reformat my external harddisk to FAT32 too. Oh wait. If I format it as FAT32, what would happen with my file permissions? Maybe I'll just use tar or something. Blah, blah, blah.
Wednesday, September 10, 2008
Google Chrome Browser on Mac OS X
While waiting for a Mac OS X version of the Chrome browser, I've content myself with VMWare Fusion's Unity feature instead:

Cool, huh?

Cool, huh?
Monday, July 07, 2008
Figlet Preview
Problem:
I wanted to use figlet but I can't decide which font to use.
Solution:
To inspect all fonts visually, simply do:
% cd /usr/local/share/figlet
% for i in `ls *.flf | sed -n -e 's/\(.*\)\.flf/\1/p'`; do echo Phuselage | figlet -f $i; done | less
Your mileage may vary; the font dir may be different on your operating system.
I wanted to use figlet but I can't decide which font to use.
Solution:
To inspect all fonts visually, simply do:
% cd /usr/local/share/figlet
% for i in `ls *.flf | sed -n -e 's/\(.*\)\.flf/\1/p'`; do echo Phuselage | figlet -f $i; done | less
Your mileage may vary; the font dir may be different on your operating system.
Friday, June 20, 2008
Synchronizing two CVS repositories using Mercurial
We're in a situation where we have access to some of our partner's source code. We need to keep in sync with their repo, otherwise our copy would quickly become stale.
Currently, we can do this manually because our changes are still small. A few months from now, however, our changes will eventually drift away from their code and merging it with our tree would become difficult.
A distributed version control system is in order. Here's how I did it:
In theory, exporting it back to CVS is no longer needed. In practice, however, I needed to maintain "compatibility" with my fellow developers who only use CVS. I hope we'll eventually migrate away from CVS though because merging lots of files is really time consuming. Merging/branching is CVS' main weakness.
Currently, we can do this manually because our changes are still small. A few months from now, however, our changes will eventually drift away from their code and merging it with our tree would become difficult.
A distributed version control system is in order. Here's how I did it:
+-----------------+ +------------+ +------------+ +----------------+
| Upstream | | Immutable | | Working | | Local |
| CVS repository |-------->| Mercurial |---------------->| Mercurial |-------->| CVS repository |
+-----------------+ import | repository | Mercurial pull | repository | export +----------------+
+------------+ +------------+
|^
||
||
v|
User
In theory, exporting it back to CVS is no longer needed. In practice, however, I needed to maintain "compatibility" with my fellow developers who only use CVS. I hope we'll eventually migrate away from CVS though because merging lots of files is really time consuming. Merging/branching is CVS' main weakness.
Thursday, June 19, 2008
MySQL: How to merge two databases
I'm currently managing a couple of databases in a production server. The problem: I need to know what new tables were created from Database 1 and merge them to Database 2.
Here's the solution:
0. Backup the target database.
% mysqldump -h [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database2 > Database2.sql
1. Extract the table names from the source and target databases.
% echo show tables | mysql -h [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database1 | sed '1d' > one.tables
% echo show tables | mysql -h [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database2 | sed '1d' > two.tables
2. Perform the merge.
% mysqldump -h [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database1 \
`diff --unchanged-line-format='' --new-line-format='%l ' two.tables one.tables` | \
mysql [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database2
Here's the solution:
0. Backup the target database.
% mysqldump -h [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database2 > Database2.sql
1. Extract the table names from the source and target databases.
% echo show tables | mysql -h [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database1 | sed '1d' > one.tables
% echo show tables | mysql -h [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database2 | sed '1d' > two.tables
2. Perform the merge.
% mysqldump -h [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database1 \
`diff --unchanged-line-format='' --new-line-format='%l ' two.tables one.tables` | \
mysql [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database2
Wednesday, June 04, 2008
Unix/Linux Tip: Syntax check your PHP files
If you wish to syntax check (lint) all the PHP files in your current directory, simply do:
for i in `ls *.php`; do
php -l $i
done
for i in `ls *.php`; do
php -l $i
done
Thursday, May 29, 2008
Fedora/Redhat Linux: C/C++ : unfound library "mysql.h"
If you encounter this problem while compiling an application that links to MySQL, you can fix this by simply installing mysql-dev:
# /etc/init.d/mysqld stop
# yum install mysql-dev
# /etc/init.d/mysqld stop
# yum install mysql-dev
Subscribe to:
Posts (Atom)
