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!)

About this user

Jacob Stetser http://blog.unquiet.net/

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

List 10 largest files/directories within the current directory

From the textdrive fora

du -sk * | sort -n | tail -10


This will list the top 10 largest files and/or directories below the directory where you run this command.

Handle Maintenance Tasks for Rails Apps without Cron

This is originally from tech.rufy.com/entry/15, but half the time I can't access his site so I'm storing it here. He usually has this code in the index actions of his site.

It checks for an existing process and if it doesn't find one, spawns a new thread to handle maintenance tasks.

pid_file = '/tmp/running.pid'
begin
  File.stat pid_file
rescue
  f = File.new pid_file, 'w'
  f < < fork {
    loop {
      # do lots of maintenance
      sleep 15*60
    }
  }
  f.close
end

MySQL launchd item for Mac OS X Tiger

(Originally posted at Unquiet)

I had to reinstall Mysql because it wasn�t one of the things I backed up before erasing my hard drive. Since I�m now running Mac OS X 10.4 �Tiger�, I decided to set it up to start when the system boots, but the system for creating startup items has changed slightly. So I saved the following xml in /Library/LaunchDaemons/com.mysql.Mysql.plist:

<?xml version="1.0" encoding="UTF-8"?>
    DOCTYPE plist PUBLIC 
         "-//Apple Computer//DTD PLIST 1.0//EN" "
        http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Labelkey>
        com.mysql.Mysql</string>
        <key>OnDemandkey>
        />
        <key>ProgramArgumentskey>
        
                /usr/local/mysql/bin/mysqld_safestring>
        </array>
        <key>ServiceDescriptionkey>
        Mysql 4.1 Database Server</string>
        <key>UserNamekey>
        mysql</string>
        <key>WorkingDirectorykey>
        /usr/local/mysqlstring>
    </dict>
    plist>


Note that I'm using the official OSX distribution of MySQL... but with a few changes to match your database location, you can get this to work with other installs (fink, darwinports, etc).

Wordpress clean URLS with Lighttpd, the E-Z way

This single line seems to work for my WP install. I needed to add a couple of redirects and rewrites to handle my RSS feed, since I use Feedburner, but this line does all the heavy lifting...

Place it after server.document-root, either in the main section or in your virtual host sub-sections...

server.error-handler-404 = "/index.php?error=404"


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