Skip to content

Instantly share code, notes, and snippets.

@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,";
@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: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 / 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 / .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 / 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 / navigation.php
Created August 5, 2013 12:52
navigation.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Navigation {
var $menu = array(); //The array holding all navigation elements
var $out; // The HTML string to be returned
/*
* Render the top nav
*/
<?php if(isset($nav) && !empty($nav)) echo $nav; ?>
@haganbt
haganbt / gist:6447674
Created September 5, 2013 08:55
DataSift CSDL filter - tracking tweets from France in French
/*
* http://simple.wikipedia.org/wiki/List_of_cities_in_France
*
*/
(
// GEO
interaction.geo geo_polygon "51.08282186160978,2.548828125:50.816347765191075,2.63671875:50.68775800806201,2.900390625:50.78510168548186,3.131103515625:50.53088873891836,3.2794189453125:50.523904629228625,3.4716796875:50.31039245071915,3.71337890625:50.3454604086048,4.031982421875:50.257741984396894,4.2352294921875:50.13466432216696,4.1473388671875:50.06066538593667,4.229736328125:50.01832895590886,4.1473388671875:49.9759551873433,4.1473388671875:49.94061518401988,4.4769287109375:50.004208515595614,4.6746826171875:50.15930523913416,4.7735595703125:50.152266272562684,4.8834228515625:49.97242235423708,4.801025390625:49.85569332253434,4.8614501953125:49.75997752330658,5.0811767578125:49.710272582105695,5.16357421875:49.64273443429918,5.3338623046875:49.48240137826932,5.482177734375:49.55728898983402,5.745849609375:49.44670029695473,6.1083984375:49.468124067331644,6.4434814453125:49.35375571830993,6.580810546875:49.160154652338
cluster.name: datasift
cloud:
aws:
access_key: ***************
secret_key: ************************
region: eu-west-1
discovery:
type: ec2
gateway:
type: s3