Skip to content

Instantly share code, notes, and snippets.

@haganbt
haganbt / routes.php
Last active December 20, 2015 15:39
Coudeigniter - routing static pages
<?php
// Route ALL requests to the static page handler
$route['default_controller'] = "pages";
// All other static pages
$route['(:any)'] = "pages/$1";
@haganbt
haganbt / .htaccess
Created August 5, 2013 12:45
CodeIgniter - htaccess - Remove index.php from url's
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
@haganbt
haganbt / pages.php
Created August 5, 2013 12:41
Pages Controller - Manage static pages
<?php
class Pages extends CI_Controller {
function _remap($method)
{
is_file(APPPATH.'views/pages/'.$method.'.php') OR show_404();
$headerdata['title'] = ucfirst($method);
$headerdata['nav'] = $this->navigation->load($method);
@haganbt
haganbt / gist:4117429
Created November 20, 2012 11:36
DataSift Push API - PHP HTTP POST Receiver Examples
<?php
if (!function_exists('apache_request_headers')) {
function apache_request_headers() {
foreach($_SERVER as $key=>$value) {
if (substr($key,0,5)=="HTTP_") {
$key=str_replace(" ","-",ucwords(str_replace("_"," ",substr($key,5))));
$out[$key]=$value;
}
}
return $out;
@haganbt
haganbt / gist:2231867
Created March 29, 2012 00:37
DataSift Interaction with Socket.io
consumer.on("interaction", function(obj) {
if(obj.data !== undefined) {
//console.log(obj.data);
io.sockets.emit('data', {
source : obj.data
});
}
});
@haganbt
haganbt / gist:1933308
Created February 28, 2012 15:56
Create MySQL table from a DataSift CSV export.
<?php
/* Generate MySQL - CREATE TABLE and LOAD DATA LOCAL INFILE statements from a DataSift CSV file */
// Edit with file location and name.
$myFile = "test.csv";
$lines = file($myFile);
$fields = preg_split('/,/', $lines[0]);
$create = "CREATE TABLE IF NOT EXISTS `Interactions` (`intId` int(11) NOT NULL auto_increment,";