Never been to CodeSnippets 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

Jason Hoffman http://textdrive.com/

Grandma's Banana Bread

1.5 cups of sugar
1 cup of crisco
2.5 cups of flour
2 tsp baking soda
6 bananas (ripe, a little brown)
4 eggs


mix crisco and sugar, then mix eggs into it, then banana.

sift baking soda and flour together and fold it into the mix above.

put it in whatever you want to cook it (little loaf pans for example).

bake at 350 degree farenheit until the top is a bit brown.

Killing an outta whack webmin

ps ax | grep webmin | kill -9 `awk '{print $1}'`

Chained SSL certs in lighttpd

ssl.ca-file = "/usr/local/openssl/certs/chain.ca.crt"
ssl.pemfile = "/usr/local/openssl/certs/server.pem"

Mod_PHP that co-exists with PHP-CGI-FCGI

This is how you do the mod_php version of php-cgi-fcgi that co-exists quite nicely.

Do this one after the cgi-fcgi because what'll do is move the PHP-CLI into /usr/local/bin/php

You do need to have installed apache2.

Libxml also has to be there in /usr/local/ or if you are on Mac's Tiger, you can change the path to /usr and that should do ya.

./configure --enable-memory-limit --with-layout=GNU --with-config-file-scan-dir=/usr/local/etc/php --disable-all --enable-libxml --with-libxml-dir=/usr/local --enable-spl --with-regex=php --with-apxs2=/usr/local/apache2/sbin/apxs --prefix=/usr/local

Minimal extension-less build of PHP-CGI-FCGI

But what you do is add the --with-config-file-scan-dir where you add an extra extensions.ini file that dynamically loads different php extensions that you compile separately.

You will need to have compiled and installed libxml into /usr/local/ or if you are on Mac's Tiger, you can change the path to /usr and that should do ya.

./configure --enable-memory-limit --with-layout=GNU --with-config-file-scan-dir=/usr/local/etc/php --disable-all --enable-libxml --with-libxml-dir=/usr/local --enable-spl --with-regex=php --disable-cli --enable-force-cgi-redirect --enable-fastcgi


And you don't want to leave that /usr/local/bin/php binary sitting there because it's cgi-fcgi, you're going to replace it with php-cli

mv /usr/local/bin/php /usr/local/bin/php-fcgi


/usr/local/bin/php-fcgi is then the binary you use for all PHP CGI and FCGI.

SVNnotify post-commit hook

For example, the post-commit hook for the repository named "repos"
pacific# cat /home/svn/repos/hooks/post-commit


is

#!/bin/sh
REPOS="$1"
REV="$2"
/usr/local/bin/svnnotify -r $REV -C -d -H HTML::ColorDiff -p $REPOS -t staff@lists.textdrive.com --from jason@textdrive.com --reply-to staff@lists.textdrive.com

rip calendar attachments from an email (in ruby)

See here for context.

I did this for undees

#!/usr/local/bin/ruby
$: << '/home/username/usr/local/lib/ruby/site_ruby/1.8'
require 'tmail'

s = $stdin.read
mail = TMail::Mail.parse s
mail.parts.each do |part|
  if 'text/calendar' == part.content_type
    t = part.body
    t.gsub!(/=[\r\n]+/, '')
    t.gsub!(/=(\w\w)/) {$1.hex.chr}
    
    outPath = '/home/username/path/to/Calendar.ics'
    File.open outPath, 'w' do |f|
      f.write t
    end
    File.chmod 0664, outPath    
  end
end

Paula Deen's southern fried chicken recipe

I love the Paula Deen's fried chicken recipe but I'm always having to look up the URL:

3 eggs 
1/3 cup water 
About 1 cup hot red pepper sauce (recommended: Texas Pete) 
2 cups self-rising flour 
1 teaspoon pepper 
House seasoning, recipe follows 
1 (1 to 2 1/2-pound) chicken, cut into pieces 
Oil, for frying, preferably peanut oil
In a medium size bowl, beat the eggs with the water. Add enough hot sauce so the egg mixture is bright orange. In another bowl, combine the flour and pepper. Season the chicken with the house seasoning. Dip the seasoned chicken in the egg, and then coat well in the flour mixture. 
Heat the oil to 350 degrees F in a deep pot. Do not fill the pot more than 1/2 full with oil.
Fry the chicken in the oil until brown and crisp. Dark meat takes longer then white meat. It should take dark meat about 13 to 14 minutes, white meat around 8 to 10 minutes.

House Seasoning: 
1 cup salt 
1/4 cup black pepper 
1/4 cup garlic powder
Mix ingredients together and store in an airtight container for up to 6 months.

Forcing an SVN export to overwrite a directory

You can run --force to make an SVN export overwrite a folder rather than write into it

cd /usr/local/etc/
svn export --force --username user@textdrive.com --password apassword https://svn.textdrive.com/repos/setup/usr/local/etc/apache2

Mixed example of mod_deflate configuration for httpd.conf

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
SetInputFilter DEFLATE
#the two above compress everything unless excluded below
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary              
SetEnvIfNoCase Request_URI \.avi$ no-gzip dont-vary             
SetEnvIfNoCase Request_URI \.mov$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp4$ no-gzip dont-vary     
SetEnvIfNoCase Request_URI \.rm$ no-gzip dont-vary      
SetEnvIfNoCase Request_URI \.plist$ no-gzip dont-vary   
# Below is an example where you get rid of what's above and you explicity compress
AddOutputFilterByType DEFLATE application/x-httpd-php application/x-httpd-fastphp application/x-httpd-eruby text/html 
DeflateFilterNote ratio
DeflateCompressionLevel 9
</IfModule>