Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
7 total  XML / RSS feed 

Protect .svn directories server-wide (Apache)

// protect ".svn" and "CVS" dirs (could add more)
// for server-wide protection; goes in httpd.conf
// there's a separate snippet for .htaccess-based code

<DirectoryMatch "^/.*/(\.svn|CVS)/">
  Order deny,allow
  Deny from all 

Retrieve MSSQL table information

Retrieve tons of information (length, data type, name, etc.) of columns for a table. Works in (T|MS)SQL (all I've tested it in).

SELECT * FROM information_schema.columns WHERE table_name = 'Customers'

Serve php within .htm

In your .htaccess file (maybe only in a specific folder) add this line to parse a .htm as a php file. This works on TxD accounts.
AddType application/x-httpd-php .htm .php


// Simple ruby webrick server

require 'webrick'

# The :AccessLog configuration takes an array.
# Each element of the array should be
# a two-element array where the first element
# is the stream (or anything responding to <<)  and
# the second element is the access log format.
# Please see webrick/accesslog.rb for available formats.

access_log_stream ='C:\\Documents and Settings\\madann\\My Documents\\access.log', 'w')
access_log = [ [ access_log_stream, WEBrick::AccessLog::COMBINED_LOG_FORMAT ] ]

DocumentRoot = 'C:\\Documents and Settings\\madann\\My Documents\\Public_html\\';
HTTPPort = 8008

   d =
   puts "Creating Documentroot"
   mkdir DocumentRoot

class DownloadHandler < WEBrick::HTTPServlet::AbstractServlet
    def do_get(req,resp)
        p "req : ",req
        p "resp : ",resp

    def go_post(req,resp)

s =
  :Port             => HTTPPort,
  :DocumentRoot     => DocumentRoot,
  :FancyIndexing    => true
  #:Logger          =>'download.log'),
  #:AccessLog       => access_log

        "C:\\Documents and Settings\\madann\\My Documents\\Public_html\\cgi-bin\\",

trap("INT"){ s.shutdown }

server optimization

- Why not use mod_negotiation for compression? That will allow you to use pre-compressed files and avoid per-request on-the-fly compression. You can automate this and use the most expensive/effective compression level (gzip -9 foo).

- Separate static content, dynamic content, and database onto separate machines.

- Serve static content from a machine with lots of RAM to allow OS- or server-level file caching. Check out a built-for-speed server like lighttpd.

- Compile a stripped-down version of your Web server using only the modules you need.

- For frequently-called, brain-dead utility work like “Bringing it all together”, avoid PHP like the plague. Write it in C using FastCGI.

- For big PHP, use the Zend Optimizer. Check out the PHP5 function benchmarks at

- All the usual stuff: don’t follow symlinks, don’t use .htaccess files, don’t resolve client hostnames (move the logs to another machine and batch it later), etc..

- If you use SSL, buy a dedicated hardware SSL device that offloads crypto processing from the servers to it.

- When linking to directories, add the trailing slash. i.e. rather than This avoids an HTTP redirect, which results in an unncessary HTTP transaction.

Trac: Running the Standalone Server

Running the Standalone Server
After having created a Trac environment, you can easily try the web interface
by running the standalone server tracd:
  $ tracd --port 8000 /path/to/projectenv

Then, fire up a browser and visit http://localhost:8000/. You should get a
simple listing of all environments that tracd knows about. Follow the link
to the environment you just created, and you should see Trac in action.

Search for open files that won't allow you to unmount a server volume

lsof | grep "Office Server"

Lists out all open files on a given volume ("Office Server" in this case.) Good to find those peskey open files that won't let you eject a mounted network volume.
« Newer Snippets
Older Snippets »
7 total  XML / RSS feed