Archive for September, 2009

Linux: IPTables

Sunday, September 27th, 2009

Enable HTTPS

iptables -I INPUT 1 -s 0/0 -i eth0 -d 0/0  -p TCP --dport 443 -j ACCEPT
  • -I INPUT 1: Insert at position #1 (do
  • -s 0/0: Any source IPs
  • -d 0/0: Any destination IPs
  • -p TCP: TCP protocol
  • –dport 443: Port number (for ssl, default is 443)

Related Links

Apache: Install SSL on Virtual Host

Sunday, September 27th, 2009

Here is the minimum configuration to enable SSL

Load the module and configure the certificate

LoadModule ssl_module modules/
Listen 443
SSLProtocol all -SSLv2
SSLCertificateFile /path/to/domain-certificate.crt
SSLCertificateKeyFile /path/to/domain-key.key
SSLCertificateChainFile /path/to/bundle-certificate.crt
SSLCACertificateFile /path/to/bundle-certificate.crt


NameVirtualHost *:443
<VirtualHost *:443>
DocumentRoot /path/to/html/
SSLEngine on


  1. Disable your /etc/httpd/conf.d/ssl.conf by renaming it to ssl.conf.disabled (otherwise, Apache will take the properties from this file, and it can get quite confusing).
  2. Open your firewall for https protocol
  3. Get a certificate (Godaddy have the cheapest one, especially for wildcard ones)

Related links

Windows: Flush (Clear) DNS Cache

Thursday, September 24th, 2009
ipconfig /flushdns

RegEx: Selecting html tag content

Wednesday, September 23rd, 2009

RegEx to select the content of div.code

<divb class=.code[^>]*>([sS]*?)</div>


<div class="cdeBlock">
<div class="cdeLbl">HTML: /snowReport?resort=Tahoe</div>
<div class="code html"><p>Hello, there are ${m.newSnowInch} inches
 of new Snow in ${r.p.resort} </p></div>

<div class="cdeBlock">

Eclipse: Escape string when pasting

Tuesday, September 8th, 2009
  1. Go to: Window>Preference>Java>Editor>Typing
  2. Check the box: Escape text when pasting into a string literal
Source: Eclipse Tip: Escape text when pasting

WordPress: Get template variables (post id, category id)

Monday, September 7th, 2009

Get current category

<?php $current_category = single_cat_title("", false); ?>

Source: – single_cat_title

Get current post in a loop

<?php $current_post = get_the_ID() ?>

Source: – getId

Linux: Tar cheat sheets

Monday, September 7th, 2009

Best short article on this subject: How to create and extract zip, tar, tar.gz and tar.bz2 files in Linux

Tar and gzip the folder panda/ in the panda.tar.gz

tar -cvzf panda.tar.gz panda/


tar -xvzf panda.tar.gz

or (to change the base folder name)

tar -xvzf latest.tar.gz -C ./(folder name)


MySQL: Shell script to backup mysql database

Monday, September 7th, 2009
tdy=`date +%Y-%m-%d-%H-%M`
mkdir /var/backup/db_name/$tdy
mysqldump -u db_user -p --opt db_name > /var/backup/db_name/$tdy/db_name-$tdy.sql

Javascript: Date library datejs

Friday, September 4th, 2009