Skip to content

Instantly share code, notes, and snippets.

View Medalink's full-sized avatar

Eric Percifield Medalink

View GitHub Profile
@Medalink
Medalink / list_dir.php
Created January 30, 2012 22:50
PHP Directory Listing w/Extension Filter
<?php
$dir = '.';
if( $handle = opendir( $dir ) ) {
while( false !== ( $entry = readdir( $handle ) ) ) {
if( preg_match( '/.html/', $entry ) ) {
echo "$entry\n";
}
}
closedir( $handle );
}
@Medalink
Medalink / replace_text_once.php
Created February 2, 2012 17:10
PHP Replace Text Once
<?php
function str_replace_once( $str_pattern, $str_replacement, $string ){
if( strpos( $string, $str_pattern ) !== false )
{
$occurrence = strpos( $string, $str_pattern );
return substr_replace( $string, $str_replacement, strpos( $string, $str_pattern ), strlen( $str_pattern ) );
}
return $string;
}
@Medalink
Medalink / date.php
Created March 7, 2012 17:55
Date Helper
<?php
class Date {
public static function ago( $time ) {
$time = time() - 25;
$periods = array( 'second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade' );
$lengths = array('60','60','24','7','4.35','12','10');
$now = time();
$difference = $now - $time;
@Medalink
Medalink / auth.php
Created March 13, 2012 20:13
Register & Email validation
<?php
/**
* Validate registration data for our system
*
* @param array
* @param boolean
* @return Redirect with array
*/
public function post_register( $data = NULL, $email_confirm = true ) {
if( !empty( $data ) ) // Directly set the data so we can use it as normal
<?php
/*
Plugin Name: Theme Updater
Plugin URI: https://github.com/UCF/Theme-Updater
Description: A theme updater for GitHub hosted Wordpress themes. This Wordpress plugin automatically checks GitHub for theme updates and enables automatic install. For more information read <a href="https://github.com/UCF/Theme-Updater/blob/master/readme.markdown">plugin documentation</a>.
Author: Douglas Beck
Author: UCF Web Communications
Version: 1.3.4
*/
<?php
class Crud_Base_Controller extends Base_Controller {
// Yes, i want restfull, god yesssss
public $restful = true;
public function __construct()
{
// This is required in order to bring in functionality from laravel.
@Medalink
Medalink / dabblet.css
Created June 7, 2012 19:03
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@Medalink
Medalink / dabblet.css
Created July 3, 2012 19:23 — forked from alexmwalker/dabblet.css
CSS3 Animated Flames *
/**
* CSS3 Animated Flames *
Improved version using the 'steps' attribute to control the sprite switching
*/
body {background-color:#000}
#logfire {
position:relative;
background:url(http://sitepointstatic.com/examples/css3/animation/logfire.jpg?r=2) center top no-repeat;
@Medalink
Medalink / folder_to_smil.php
Created October 1, 2012 16:17
SMIL Generator
<pre>
SMIL Information:
<?php
// RTMP URL
define( "RTMP_URL", "rtmp://glc.us.com/vod" );
// Video Directory.
//define( "VIDEO_DIR", realpath( dirname( __FILE__ ) . "/glcmedia/video/" ) );
// Manual
define( "VIDEO_DIR", realpath( "/Server/www/GLC/glc.us.com/trunk/glcmedia/video" ) );
@Medalink
Medalink / cronjobs.sh
Created April 24, 2013 18:05
List crontab for all users on machine.
#############################################################
# File: cronjobs.sh
# Description: List crontab for all users on machine
#
# Supported OS: Ubuntu, should work with other distributions
#
# Author: Eric Percifield
# http://www.tge-studio.com
#
#############################################################