Skip to content

Instantly share code, notes, and snippets.

View trey's full-sized avatar
🏠
I'd rather be at home

Trey Piepmeier trey

🏠
I'd rather be at home
View GitHub Profile
@trey
trey / gist:134595
Created June 23, 2009 15:32
Hostname switching in PHP, Python, and Ruby
$localServers = array('something.dev');
$stagingServers = array('something_else.com', 'and_another.com');
if (in_array($_SERVER['HTTP_HOST'], $localServers)) {
// Development settings
} elseif (in_array($_SERVER['HTTP_HOST'], $stagingServers)) {
// Staging settings
} else {
// Production settings
}
#! /usr/bin/env ruby
#
# Save in your path as "isreg" and chmod +x. Then: isreg domain.com
#
puts `whois #{ARGV[0]}` =~ /No match for \"#{ARGV[0]}\"/mi ? "No" : "Yes"
#!/bin/bash
#
# Save in your .bash_profile then: isreg domain.com
function isreg {
dig soa $1 | grep -q ^$1 && echo "Yes" || echo "No"
}
@trey
trey / YQL
Created November 7, 2009 07:42
How beards.trey.cc works. Be sure to note the YQL snippet at the bottom. Make your own at http://developer.yahoo.com/yql/console/
use 'http://yqlblog.net/samples/data.html.cssselect.xml' as data.html.cssselect; select * from data.html.cssselect where url="http://whiskerino.org/2009/beards/trey/favorites/" and css="#gallerywidemouth div"
@postpostmodern
postpostmodern / 404.html
Last active February 20, 2022 01:34
My custom configurations for apache 2.2
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page Not Found</title>
<style type="text/css" media="screen">
body {
background: #f0f0f0;
font: normal 18px sans-serif;
width: 400px;
@trey
trey / treyvhost
Created February 1, 2010 21:06
Create a new project based on my site-template project.
#!/bin/sh
# Original script by Jason Tan: http://solutions.treypiepmeier.com/2009/03/03/virtual-hosts-on-osx-leopard/#comment-41787
DIR=/Users/$SUDO_USER/Sites/$1
if [[ ! -d $DIR && `id -u` -eq 0 ]]; then
echo ""
echo "Downloading site-template repository ..."
sudo -u $SUDO_USER git clone --quiet git://github.com/trey/site-template.git $DIR
cd $DIR

Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard)

Install Homebrew

sudo mkdir /usr/local
sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
brew install git
cd /usr/local
git init
@trey
trey / requirements.txt
Created March 5, 2010 04:53
PIP requirements file for ComicBinder
docutils==0.6
django-tagging
sorl-thumbnail
django-gravatar
django-debug-toolbar
PIL
-e hg+http://bitbucket.org/ubernostrum/django-registration/#egg=Registration
-e git://github.com/mintchaos/typogrify.git#egg=Typogrify
-e git://github.com/simonw/django-html.git#egg=django_html
-e svn+http://code.djangoproject.com/svn/django/trunk#egg=Django
@trey
trey / wp-config.php
Created March 8, 2010 21:16
Flexible WordPress Configuration
define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content' );
define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/wp-content');
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME'] . '');
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/wordpress');
/* More info: http://solutions.treypiepmeier.com/2008/05/28/installing-wordpress-the-right-way/ */
@MicahElliott
MicahElliott / colortrans.py
Created November 29, 2010 07:57
Convert values between RGB hex codes and xterm-256 color codes.
#! /usr/bin/env python
""" Convert values between RGB hex codes and xterm-256 color codes.
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
* http://en.wikipedia.org/wiki/8-bit_color
* http://en.wikipedia.org/wiki/ANSI_escape_code