Skip to content

Instantly share code, notes, and snippets.

@kwd
kwd / gist:3149572
Created July 20, 2012 08:22 — forked from jnaskali/gist:2000090
CSS: Sticky footer
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
@kwd
kwd / gist:3149571
Created July 20, 2012 08:22 — forked from jnaskali/gist:2000084
CSS: Container Clearfix
#content { overflow: hidden; width: 100%; }
@kwd
kwd / gist:3149569
Created July 20, 2012 08:22 — forked from jnaskali/gist:2000041
Bash: backup mysql database to email from ssh or cron
/bin/nice -n 19 mysqldump -e --user=DBUSER --password=DBPASS DATABASE | gzip | uuencode mysql_backup.gz | mail -s "Automatic mysql backup" your@email.com >/dev/null 2>&1
@kwd
kwd / gist:3149568
Created July 20, 2012 08:22 — forked from jnaskali/gist:2000102
PHP: Send XML over POST with cURL and save response
function sendXmlOverPost($url, $xml) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// For xml, change the content-type.
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
@kwd
kwd / gist:3149565
Created July 20, 2012 08:21 — forked from jnaskali/gist:2000115
PHP: Mail utf8
function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') {
$header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header);
}
@kwd
kwd / gist:3149564
Created July 20, 2012 08:21 — forked from jnaskali/gist:2000116
PHP: htaccess password auth
if (isset($HTTP_SERVER_VARS['PHP_AUTH_USER']) && !empty($HTTP_SERVER_VARS['PHP_AUTH_USER']) && isset($HTTP_SERVER_VARS['PHP_AUTH_PW']) && !empty($HTTP_SERVER_VARS['PHP_AUTH_PW'])) {
$redirect_origin['auth_user'] = $HTTP_SERVER_VARS['PHP_AUTH_USER'];
$redirect_origin['auth_pw'] = $HTTP_SERVER_VARS['PHP_AUTH_PW'];
}
@kwd
kwd / gist:3149562
Created July 20, 2012 08:21 — forked from jnaskali/gist:2000138
OsCommerce: Export customer email list
<?php
mysql_connect(localhost,'USER','PASS');
@mysql_select_db('DATABASE') or die( "Unable to select database");
$sql = 'SELECT customers_email_address FROM customers';
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
@kwd
kwd / gist:3149560
Created July 20, 2012 08:21 — forked from jnaskali/gist:2000158
PHP: Convert MYSQL MyISAM to InnoDB
<?php
#This script will change all the table engine types for a given database!
#All the DB tools I have (GNU/freeware) will not change a list of database
# types, so this script saves time when a CMS or other populates a database
# with tables we cannot use! This can be migrated to InnoDB by changing line
# 23, col 46 from MyISAM to InnoDB (double check the capitals there!).
# Change these variables relative: serverName, userName, password, databaseName
# 20051410 JLynch
# myisamFixer.php
@kwd
kwd / gist:3149558
Created July 20, 2012 08:21 — forked from jnaskali/gist:2000173
htaccess: Maintenance mode, allow own ip through
# FOR MAINTENANCE ONLY
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/maintenange.html$
RewriteCond %{REMOTE_HOST} !^000\.000\.000\.000
RewriteRule $ /maintenance.html [R=302,L]
# REMOVE FOR MAINTENANCE ONLY
@kwd
kwd / gist:3149556
Created July 20, 2012 08:21 — forked from jnaskali/gist:2000188
htaccess: Generic canonization (both no-www2www and www2no-www)
Non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]