August 2008 Archives

Sample iptables config for a web server

| | Comments (0) | TrackBacks (0)

I've cribbed this sample iptables config from the one at IPTablesRocks - basically restricting the incoming ports down to SSH (port 22) and HTTP (port 80). Be sure to follow their precautions before trying to change your iptables - get it wrong and it could cost you a fair price to get your web hosts to flush your iptables.

Add Options to a Select with jQuery : IE7

| | Comments (2) | TrackBacks (0)

Problem: trying to add a new option to a select drop-down menu doesn't display the text in IE7.

Solution:

var thisValue = 12;
var thisText  = 'December';
var thisOpt   = document.createElement('option');
thisOpt.value = theValue;
thisOpt.appendChild(document.createTextNode(thisText));

$(".months_menu").append(thisOpt);

MySQL: Selecting non-unique records

| | Comments (0) | TrackBacks (0)

Scenario: you want to select all records that have a non-unique value in a column. Use a subquery:

SELECT ... FROM ...
WHERE ... IN (
   SELECT ... FROM ...
   GROUP BY ... HAVING COUNT(*) > 1
);

So, to give an example, you want to select all rows from the table "books" that have a non-unique title:

SELECT * FROM books
WHERE title IN (
   SELECT title FROM books
   GROUP BY title HAVING COUNT(*) > 1
);

Creating unix times from datetime stamps

| | Comments (0) | TrackBacks (0)

Scenario: you want to convert "2008-08-02 12:45:01" to the unix epoch time:

use Time::Local qw/timegm/;

my $dt = "2008-08-02 12:45:01";
my @datetime  = split /\-|:|\s/, $dt;
$datetime[1]--; # months need decrementing
my $epoch_time = timegm(reverse @datetime);

About this Archive

This page is an archive of entries from August 2008 listed from newest to oldest.

July 2008 is the previous archive.

October 2008 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.21-en