Skip to content

Instantly share code, notes, and snippets.

View xeoncross's full-sized avatar

David Pennington xeoncross

View GitHub Profile
@xeoncross
xeoncross / 808.avi.fix.sh
Created February 12, 2011 21:59
Fix the 808 camera avi file on linux
mencoder -idx MOVI0007.avi -ovc copy -oac copy -o mov7.avi
@xeoncross
xeoncross / xdebug.js
Created February 15, 2011 19:00
Activate xdebug profiler on pages you want.
javascript:if(document.URL.indexOf('XDEBUG_PROFILE')<1){var%20sep=document.URL.indexOf('?');sep%20=%20(sep<1)?'?':'&';window.location.href=document.URL+sep+'XDEBUG_PROFILE';}
@xeoncross
xeoncross / couch.sh
Created February 23, 2011 03:25
Directions on getting everything needed for running couchdb and the sample sofa blog.
# Install couchDB
sudo apt-get install couchdb
# If using Ubuntu < 11 you need a more recent version of couchdb (+1.0)
sudo apt-add-repository ppa:ubuntuone/stable
sudo apt-get update
sudo apt-get upgrade
# Method A: Install using python
sudo apt-get install python-setuptools
@xeoncross
xeoncross / mysql.tricks.sh
Created March 11, 2011 20:59
MySQL snippets for backup, restore, users, statistics, etc..
# Import SQL file (those too big for phpMyAdmin
mysql -u username -p -h localhost database-name < data.sql
# Copy data from one table schema to another (useful when structure is similar between tables)
INSERT INTO table1 ( `username`, `email`, `password`, `firstname`, `lastname`, `created`)
SELECT `username`, `email`, `password`, `firstname`, `lastname`, UNIX_TIMESTAMP() FROM table2
# Make sure you set the RIGHT host when you create a new user (127.0.0.1 vs localhost vs an IP vs "%")
# Create new User and give them access to database
@xeoncross
xeoncross / o.php
Created April 12, 2011 21:20
Auto Object Loading
<?php
class o
{
private $o;
// Get value
public function __get($k){return isset($this->o[$k])?$this->o[$k]:NULL;}
// Create or Get value
<?php
/**
* Return an array of locales based on HTTP "Accept-Language" header.
*
* @return array
*/
function accept_languages()
{
if(preg_match_all('/[\-a-z]{2,}/i', getenv('HTTP_ACCEPT_LANGUAGE'), $matches))
{
@xeoncross
xeoncross / commands.sh
Created May 4, 2011 18:33
Linux Commands
// chmod only files (leaving directories as-is)
find . -type f -exec chmod 644 {} \;
// CHMOD only directories (leave files as-is)
find . -type d -exec chmod 755 {} \;
// Convert a folder of PSD images to PNG (or JPG) previews (requires ImageMagick to be installed)
convert *.psd[0] -set filename:orig %t %[filename:orig].png
@xeoncross
xeoncross / bash.sh
Created May 26, 2011 16:00
BASH coding
# To check if a directory exists in a bash shell script you can use the following:
if [ -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY exists
fi
# Or to check if a directory doesn't exist:
if [ ! -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY doesn't exist
fi
@xeoncross
xeoncross / postfix.sh
Created May 30, 2011 17:06
postfix install
We need to setup Postfix
vim /etc/hostname
vim /etc/hosts
[
apt-get install dnsutils
dig -x 111.111.111.111
] or [
host 173.255.192.25
] or [
@xeoncross
xeoncross / postgresql.sh
Created June 4, 2011 20:06
PostgreSQL Commands
# install postgresql
$ sudo apt-get install postgresql
# Login as postgres user
$ sudo -u postgres psql postgres
# Set a password for the "postgres" database role using the command:
$ \password postgres
# Creating a new PostgreSQL user