geek: 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
);

About this Archive

This page is a archive of entries in the geek category from August 2008.

geek: July 2008 is the previous archive.

geek: 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