Skip to content

Instantly share code, notes, and snippets.

View ctrl-freak's full-sized avatar

Bryce Sheehan ctrl-freak

View GitHub Profile
@ctrl-freak
ctrl-freak / outline-numbering.css
Created June 20, 2011 03:10
Sequential Outline Numbering of Ordered Lists
ol {list-style: none;}
body > ol { counter-reset:level1;}
body > ol > li { counter-increment:level1; }
body > ol > li:before {content: counter(level1) " "; }
body > ol > li > ol { counter-reset:level2; }
body > ol > li > ol > li { counter-increment:level2; }
body > ol > li > ol > li:before { content: counter(level1) "." counter(level2) " "; }
@ctrl-freak
ctrl-freak / htaccess_timthumb
Created June 30, 2011 07:48
Rewrite for TimThumb.php Thumbnail Generation
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/([0-9]+)/(.+)$ index.php?src=$3&w=$1&h=$2&q=90&zc=2 [L]
@ctrl-freak
ctrl-freak / nice-filter-terms.php
Created July 11, 2011 06:51
Nice Filter Terms in PHP
<?
if ($url_parts[1]!='')
{
$args = array();
for($i=0; $i<count($url_parts);$i++) {
switch($url_parts[$i]) {
case 'page':
{
$args['page']=$url_parts[$i+1];
break
@ctrl-freak
ctrl-freak / moneyify.php
Created July 12, 2011 01:33
Moneyify MySQL DECIMAL Value
<?
function moneyify($value) {
$value = ((int)$value == (float)$value) ? (int)$value : (float)$value;
$value = number_format($value);
return $value;
}
?>
@ctrl-freak
ctrl-freak / url_parts.php
Created July 12, 2011 01:38
PHP $url_parts
<?
$url=str_replace('.html','',$_GET['u']);
$page_url=$url;
$args=array();
if(strstr($url,'?'))
{
$url=explode('?',$url);
$tmp=$url[1];
$tmp=explode('&',$tmp);
@ctrl-freak
ctrl-freak / truncate-string-word-wrap.php
Created July 21, 2011 04:48
Truncate String and Word Wrap
<?
preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, 201));
?>
@ctrl-freak
ctrl-freak / listening-servers.sh
Created August 2, 2011 04:10
List Listening Servers on Linux
#!/bin/bash
sudo netstat -anp | grep LISTEN
@ctrl-freak
ctrl-freak / standby.bat
Created August 31, 2011 17:01
Standby Computer with Delay
timeout 7200 && rundll32 powrprof.dll,SetSuspendState
@ctrl-freak
ctrl-freak / html-purifier-config.php
Created September 2, 2011 08:02
HTML Purifier Configuration
<?
$purifier_config = HTMLPurifier_Config::createDefault();
$purifier_config->set('HTML.AllowedElements', 'p, a, ul, ol, li, h1, h2, h3, h4, h5, h6, br, strong, em, b, i');
$purifier_config->set('HTML.AllowedAttributes', '');
$purifier_config->set('CSS.AllowedProperties', '');
$purifier_config->set('AutoFormat.RemoveEmpty', true);
$purifier_config->set('AutoFormat.AutoParagraph', true);
// May cause problems with empty table cells and headers
@ctrl-freak
ctrl-freak / csv+headers-to-array.php
Created September 9, 2011 02:58
Read CSV File with Headers to Array
<?
$filename = $_POST['filename'];
$entries = array();
$row = 1;
if (($handle = fopen($filename, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if ($row == 1) {