Skip to content

Instantly share code, notes, and snippets.

View og-shawn-crigger's full-sized avatar

Shawn Crigger og-shawn-crigger

View GitHub Profile
@og-shawn-crigger
og-shawn-crigger / bf_modimg.php
Created May 14, 2012 05:29
Simple helper to find images in modules/assets/images Folder and return the base_url to the image.
<?php
function module_img( $image = '', $module = '' )
{
if (strlen($image) > 0 && array_key_exists('DOCUMENT_ROOT', $_SERVER) )
{
$file_path = module_file_path ('module', 'assets/images/' . $image );
$file_path = substr ( $file_path, 0, strlen($_SERVER['DOCUMENT_ROOT']) );
@og-shawn-crigger
og-shawn-crigger / content.php
Created May 15, 2012 14:09 — forked from rsmarshall/content.php
search method
public function search()
{
Console::log($this->input->get_post('search_feeds'));
$data = array(
'search_feeds' => $this->input->get_post('search_feeds')
);
Console::log($data);
$this->form_validation->set_data($data);
@og-shawn-crigger
og-shawn-crigger / config.php
Created June 19, 2012 19:12
CI Auto Base URL
//Attempts to figure out Base URL Automagically
$config['base_url'] = ((isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
function SmartPageRoutes($action, $slug=NULL, $filename=NULL, $page=NULL)
{
if($slug!=NULL) $slug = $this->_generateSlug($slug);
// Add link to routes file
$routeFile = '../primary_app/config/routes.php';
$arr = file($routeFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($arr as $key => $line)
{
if($action == 'add')
@og-shawn-crigger
og-shawn-crigger / phone_callback.php
Created June 27, 2012 19:07
Various Codeigniter Form Callbacks
/**
* Form Validation callback to format phone numbers properly.
*
* @param string $number Current phone number, should be 10 chars
*
* @return string|bool Formatted phone number in (XXX)-XXX-XXXX or FALSE if failed.
*/
public function _phone_formater($number = '')
{
$len = strlen($number);
@og-shawn-crigger
og-shawn-crigger / MY_Ouput.php
Created July 12, 2012 21:31
Better CodeIgniter Output Caching with APC|DEFAULT|DUMMY
<?php if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );
// ------------------------------------------------------------------------
/**
* Mobbr APC Output caching class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author Patrick Savalle
@og-shawn-crigger
og-shawn-crigger / send_email.php
Created July 13, 2012 19:52
Emailer Snippet for Bonfire.
/**
* Sends email after successful contact
*
* @param array $data Form Post Variables to send in email.
*
* @example input $data requires the following fields
*<code>
* $data = array(
* 'to' => '', // either string or array
@og-shawn-crigger
og-shawn-crigger / jquery.phonenumbers.js
Created July 20, 2012 16:00
Simple jQuery Phone Number Converter to Convert Numbers as they are typed
"use strict";
if ($("#affiliates_company_phone").length > 0)
{
$("#affiliates_company_phone").keyup(function() {
var curchr = this.value.length;
var curval = $(this).val();
@og-shawn-crigger
og-shawn-crigger / Grunt.sublime-build
Created July 20, 2012 16:29 — forked from mintbridge/Grunt.sublime-build
Sublime Text 2 - Settings, plugins and snippets
{
"cmd": ["grunt", "develop"],
"selector": ["source.js", "source.less", "source.json"],
"path": "/usr/bin"
}
@og-shawn-crigger
og-shawn-crigger / ciautocomplete.php
Created July 22, 2012 04:30
CI_Bonfire Auto Completion Docblock
/**
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Benchmark $benchmark
* @property CI_Calendar $calendar
* @property CI_Cart $cart
* @property CI_Config $config
* @property CI_Controller $controller
* @property CI_Email $email