Skip to content

Instantly share code, notes, and snippets.

View cballou's full-sized avatar

Corey Ballou cballou

View GitHub Profile
@cballou
cballou / wordpress-multi-env-apache-vhost.conf
Created August 15, 2011 13:38
Wordpress Apache VirtualHost Entry for Multi-Environment Setups
###########################
# provided by skookum.com #
###########################
# A VirtualHost entry open to Port 80
<VirtualHost *:80>
# The email address of your server admin
ServerAdmin corey@skookum.com
# The path to your Wordpress base installation directory
DocumentRoot /var/www/vhosts/skookum.com/html
@cballou
cballou / string-sanitization-optimize.php
Created December 14, 2011 13:03
String sanitization/filtering optimization in PHP
<?php
/**
* This class is our wrapper class to fix the
* inherent slowness of the parent class
*/
class Clean extends Sanitize {
public static function xss($string)
{
// base case
if (!preg_match('/[^a-zA-Z0-9_\-.\s?!,]/', $string)) {
@cballou
cballou / ttfm-core-ugly.js
Created December 21, 2011 21:27
tt.fm core JS
// makes me cry
messageListener:function(d){
if(d.hasOwnProperty("msgid")){return;}
if(d.command=="speak"){
this.showChatMessage(d.userid,d.name,d.text);
}else{
if(d.command=="newsong"){
if(this.sjEUHqPqB.time_left>10){
turntablePlayer.playEphemeral(UI_SOUND_ENDSONG,true);
}
@cballou
cballou / ttfm-room-manager.js
Created January 12, 2012 13:30
Get _room and _manager from TT.FM
var _room;
var _manager;
/**
* Function to retrieve turntable objects.
*/
function getTurntableObjects() {
// reset room
_room = null;
@cballou
cballou / zend-framework-install.sh
Created March 20, 2012 01:05
Getting Zend Tool up and running. Source code portion of blog post at http://blackbe.lt
cd /opt
wget http://framework.zend.com/releases/ZendFramework-1.11.10/ZendFramework-1.11.10.tar.gz
tar -xvf ZendFramework-1.11.10.tar.gz
cd ZendFramework-1.11.10
echo "alias zf='export ZF_CONFIG_FILE=~/.zf.ini; /opt/ZendFramework-1.11.10/bin/zf.sh'" >> ~/.bash_profile
source ~/.bash_profile
@cballou
cballou / fast-string-sort.php
Created March 24, 2012 21:38
A QUICK IMPLEMENTATION OF STRING SORT IN PHP
<?php
function sortString(&amp;$s) {
$s = str_split($s);
sort($s);
$s = implode($s);
}
// example usage prints:
// 1223344789aaaaadddefffffhhhiillllnnoorrsssuuuuwyy
$string = 'ouhlasfuywernhlasdfoulnarfiuyadf1234987234sdfailh';
@cballou
cballou / form-handler-example.php
Created March 24, 2012 21:47
SPF30 - A Spam Blocking/Prevention PHP Library
<?php
require_once('./spf30.php');
if (!empty($_POST)) {
try {
// this is an example of the form data before decryption
var_dump($_POST);
// run validation on the submitted email form
spam::validate($_POST);
@cballou
cballou / jquery-getMatchingClass-examples.js
Created March 25, 2012 11:56
The getMatchingClass plugin is useful for determing whether a singular matching element contains a particular <em><strong>partial class name</strong></em>. The idea behind the function is to allow for partial matching using a subset of jQuery selectors. h
// example one - remove class if a match is found at the beginning
$elem = $('#elemToMatch');
$.each($elem.getMatchingClass('*=classBeginsWith_'), function() {
$elem.removeClass(this);
});
// example two - perform an action if a match is found at the end
// note this is not a very good method for showing and hiding
// child elements and is only used as an example
$('#elemToMatch').click(function() {
@cballou
cballou / firebug-console-execution-time.js
Created March 25, 2012 13:23
Optimizing (and Debugging) Javascript With Firebug
console.time();
var str = '';
for (var i = 0; i < 1000; i++) {
str += i;
}
console.timeEnd();
@cballou
cballou / example-fbml-style.html
Created March 25, 2012 13:13
Overriding Facebook FBML Styling on a Canvas Page
<link rel="stylesheet" type="text/css" media="screen" href="http://www.yoursite.com/css/canvas.css?v=1.2" />
<div id="container">
<!-- AS AN EXAMPLE, WE'LL STYLE THE FB SHARE BUTTON -->
<fb:share-button class="url" href="http://www.your-site-url.com" />
</div>