Skip to content

Instantly share code, notes, and snippets.

View kennethreitz's full-sized avatar
🐍

Kenneth Reitz kennethreitz

🐍
View GitHub Profile
@kennethreitz
kennethreitz / .htaccess
Created March 29, 2010 04:55
(Passwd) Basic Authentication .htaccess example
Options +Indexes
<Files *>
AuthType Basic
AuthName "Please enter your username and password."
AuthUserFile .htpasswd
Require valid-user
</Files>
@kennethreitz
kennethreitz / Documentation.mkd
Created March 31, 2010 16:01
Markdown Documentation template w/ GitHub styling.
<style type="text/css" media="screen"> html{width: 85%; min-width: 600px;margin: 0 auto; font-family: sans-serif;} h1,h2,h3,h4,h5,h6{border:0!important;} h1{font-size:170%!important;border-top:4px solid #aaa!important;padding-top:.5em!important;margin-top:1.5em!important;} h1:first-child{margin-top:0!important;padding-top:.25em!important;border-top:none!important;} h2{font-size:150%!important;margin-top:1.5em!important;border-top:4px solid #e0e0e0!important;padding-top:.5em!important;} h3{margin-top:1em!important;} p{margin:1em 0!important;line-height:1.5em!important;} ul{margin:1em 0 1em 2em!important;}
@kennethreitz
kennethreitz / crash-ie6.wp-plugin.php
Created March 31, 2010 16:25
WordPress Plugin that instantly crashes IE6
<?php
/*
Plugin Name: Crash IE 6
Plugin URI: http://gist.github.com/350532
Description: We'll take them by force.
Version: 0.1
Author: Kenneth Reitz
Author URI: http://kennethreitz.com/
Min WP Version: 2.0
Max WP Version: 3.5
@kennethreitz
kennethreitz / backup.php
Created April 5, 2010 07:27
mediatemple-to-s3.php
#!/usr/bin/env php
<?php
set_time_limit(0);
$nDays = 300; // How many days of backups to keep?
// MySQL variables
$bBackupMySQL = true; // Do you want to backup MySQL databases?
$mysql = '/usr/bin/mysql';
$mysqldump = '/usr/bin/mysqldump';
$mysql_server = 'xxxx.com';
$mysql_username = 'xxxx';
@kennethreitz
kennethreitz / dir.js
Created April 19, 2010 21:05
returns all known methods of given object.
function dir(o){
var keys = [];
for(var key in o){
keys.push(key);
}
return keys;
}
sudo curl "http://gist.github.com/raw/372696/bffde4ea5cf23eebd8b0f4ee15708a0a9d0af7f5/ssh-copy-id" -o /usr/local/sbin/ssh-copy-id
sudo chmod +x /usr/local/sbin/ssh-copy-id
@kennethreitz
kennethreitz / jquery.browser.addEnvClass.js
Created April 21, 2010 01:12
jQuery script for adding intelligent browser and platform classes to the html tag
(function(){
var ua = navigator.userAgent;
var b = jQuery.browser;
b.engine = '';
b.mobile = false;
if(/Windows/.test(ua)){
b.os = 'win';
b.win = true;
}else if(/Mac/.test(ua)){
@kennethreitz
kennethreitz / slaughter-pyc.sh
Created April 21, 2010 01:17
Death to the bytecode!
find . -name "*.pyc" -exec rm '{}' ';'
@kennethreitz
kennethreitz / ports.sh
Created April 21, 2010 17:56 — forked from defunkt/ports.sh
List what ports are in use on OS X
sudo lsof -iTCP -sTCP:LISTEN -P
@kennethreitz
kennethreitz / wp-plugin.example.php
Created April 22, 2010 05:31
WordPress: Could it be simpler?
<?php
/*
Plugin Name: FooBar
Plugin URI: http://gist.github.com/kennethreitz/
Description: RoBar for WordPress
Version: 0.42
Author: Kenneth Reitz
Author URI: http://kennethreitz.com/
Min WP Version: 2.0