Figlet Preview
Posted on Monday, July 07, 2008 at 11:04 PM by simoncpuProblem:
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.
Synchronizing two CVS repositories using Mercurial
Posted on Friday, June 20, 2008 at 7:14 PM by simoncpuWe'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:
+-----------------+ +------------+ +------------+ +----------------+
| 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.
MySQL: How to merge two databases
Posted on Thursday, June 19, 2008 at 9:37 PM by simoncpuI'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 > one.tables
% echo show tables | mysql -h [HOST] -P [PORT] -u [USERNAME] -p[PASSWORD] Database2 > two.tables
Important: Edit one.tables and two.tables and remove the text at the top. There's a way to automate this, but let's keep it simple. Also, remember not to put any whitespace between -p and PASSWORD.
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
Unix/Linux Tip: Syntax check your PHP files
Posted on Wednesday, June 04, 2008 at 4:39 PM by simoncpuIf 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
Fedora/Redhat Linux: C/C++ : unfound library "mysql.h"
Posted on Thursday, May 29, 2008 at 11:45 PM by simoncpuIf 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
FreeBSD Tip: How to delete all IPv6 address in an interface
Posted on Saturday, April 26, 2008 at 2:08 AM by simoncpuYou can delete all IPv6 addresses in an interface using the following command (vanilla Bourne shell):
Note: replace le0 with your interface name.
while i="`ifconfig le0 | grep inet6 | grep -m 1 -v '%'`"; do
ifconfig le0 $i delete
done
Bridge problem with FreeBSD 7.0-RELEASE
Posted on Friday, April 25, 2008 at 3:12 PM by simoncpuProblem
The FreeBSD Handbook states that "if the bridge host needs an IP address, then the correct place to set this is on the bridge interface itself rather than one of the member interfaces."
With FreeBSD 6.x and FreeBSD 8.0-CURRENT, setting the IP address on the bridge works without any problem. With FreeBSD 7.0-RELEASE, however, this does not work. The OS doesn't even properly boot when the IP address is set via /etc/rc.conf.
Solution
This is probably a temporary solution, but try setting the IP address to one of the member interface. This is in direct opposition to the advice given in the Handbook, but it works for me.
If this is a bug (which I suspect it is), a patch probably exists somewhere. Please feel free to leave a comment.