Skip to content

Instantly share code, notes, and snippets.

View kenelliott-gists's full-sized avatar

kenelliott-gists

View GitHub Profile
<?php
class Foo {
public static function map(){
/*
       $file_dir = Registry::getParam("Config","file_dir")."libs/";
       $elements_dir =  "HTMLBuilder/Elements";
       $dir = Utilities::getDirRecursive($file_dir.$elements_dir);
       foreach($dir as $key => $class){
           $class_levels = explode("/",$class);
<?php
// include the cart class
include("Cart_Calculator.class.php");
// set up a test array of products.
$cart[0]['title'] = 'Product 1';
$cart[0]['price'] = isset($_REQUEST['cart'][0]['price']) ? $_REQUEST['cart'][0]['price'] : '12.99';
$cart[0]['qty'] = isset($_REQUEST['cart'][0]['qty']) ? $_REQUEST['cart'][0]['qty'] : '3';
$cart[0]['discount'] = isset($_REQUEST['cart'][0]['discount']) ? $_REQUEST['cart'][0]['discount'] : '0';
$cart[0]['tax'] = isset($_REQUEST['cart'][0]['tax']) ? $_REQUEST['cart'][0]['tax'] : '0';
@kenelliott-gists
kenelliott-gists / cart_demo.php
Created January 27, 2013 02:20
This is a demo of the PHP Cart class.
<?php
// include the cart class
include("Cart.class.php");
// a new session is required before creating the cart object
session_start();
// create a cart object
$Cart = new Cart('cart');
<?php
class Post_Test extends PHPUnit_Framework_TestCase
{
}
@kenelliott-gists
kenelliott-gists / post.php
Created September 12, 2012 18:51
post model
<?php
class Post extends Eloquent
{
}
@kenelliott-gists
kenelliott-gists / kill_dupes.pl
Created September 11, 2012 18:15
Perl: find and/or remove duplicate files
#!/usr/bin/perl -w
use strict;
use File::Find;
use Digest::MD5;
my %files;
my $wasted = 0;
find(\&check_file, $ARGV[0] || ".");
@kenelliott-gists
kenelliott-gists / .bash_aliases
Created September 11, 2012 14:54
Shell: Bash aliases
alias ls='ls -la'
alias nginx='/etc/init.d/nginx'
alias phpfpm='/etc/init.d/php5-fpm'
alias www='cd /media/psf/Home/Sites'
alias sandbox='cd /media/psf/Home/Sites/Sandbox'
alias backup='cd /media/psf/Home/Sites/Backup'
alias rmdir='rm -rf'
alias logs='cd /var/log'
alias addsite='/usr/bash-scripts/addsite.sh'
alias removesite='sh /usr/bash-scripts/removesite.sh'
@kenelliott-gists
kenelliott-gists / bue
Created September 11, 2012 05:05
Shell: Back up and edit file
#!/bin/bash
cp $1 $1.backup
vim $1
@kenelliott-gists
kenelliott-gists / mdg
Created September 11, 2012 05:03
Shell: Make Directory and Go
#!/bin/bash
mkdir -p $1
cd $1
@kenelliott-gists
kenelliott-gists / gsub_literal
Created September 11, 2012 03:45
Shell: gsub_literal (file_str_replace)
#!/bin/bash
gsub_literal() {
# STR cannot be empty
[[ $1 ]] || return
# string manip needed to escape '\'s, so awk doesn't expand '\n' and such
awk -v str="${1//\\/\\\\}" -v rep="${2//\\/\\\\}" '
# get the length of the search string
BEGIN {