Skip to content

Instantly share code, notes, and snippets.

View ruthlessfish's full-sized avatar

Shane Pearson ruthlessfish

View GitHub Profile
@ruthlessfish
ruthlessfish / Cli_Controller.php
Created August 30, 2011 04:50
CLI base controller
<?php
class Cli_Controller extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->input->is_cli_request() OR die('Access denied.');
$this->load->library('cli');
}
@ruthlessfish
ruthlessfish / setup-config.php
Created August 29, 2011 22:29
crude script to update base_url and index_page in CodeIgniter config.php
<?php
$base_url = 'http://localhost';
$index_page = '';
$find = array();
$rep = array();
if(php_sapi_name() == 'cli')
{
@ruthlessfish
ruthlessfish / output_helper.php
Created August 29, 2011 00:01
serve assets with correct content type header
<?php defined('BASEPATH') OR exit('No direct script access allowed');
if( ! function_exists('show_css'))
{
function show_css($content)
{
show_output('text/css', $content);
}
}
@ruthlessfish
ruthlessfish / haversine.php
Created August 24, 2011 21:06
haversine formula for MySQL in PHP
<?php
function haversine($lat1, $long1, $lat2, $long2)
{
return "(3959 * acos(cos(radians($lat1)) * cos(radians($lat2)) * cos(radians($long2) - radians($long1)) + sin(radians($lat1)) * sin(radians($lat2))))";
}
@ruthlessfish
ruthlessfish / MY_url_helper.php
Created August 24, 2011 20:57
Url helper function overrides
<?php defined('BASEPATH') or exit('No direct script access allowed');
/**
* Anchor Link
*
* Creates an anchor based on the local URL.
*
* @access public
* @param string the URL
* @param string the link title