Skip to content

Instantly share code, notes, and snippets.

View richcaudle's full-sized avatar

Rich Caudle richcaudle

View GitHub Profile
parameters={
"likes": false,
"posts_by_others": true,
"comments": true,
"page_likes": false,
"like_counts": true
}
# flatten before URL-encoding
// Limit to twitter + english social data
interaction.type == "twitter"
and (twitter.lang == "en" or twitter.retweet.lang == "en")
// Use FOCUS to collect data from the entire industry
and focus.content.levels.level3 any "Automotive Vehicles"
and focus.content.levels.last exists
// Exclude generic automotive categories as we want to focus on brands
and not focus.content.levels.last in "Travel Trailers,Used Vehicles,Van & Minivan Price,Van & Minivan Specifications,Vintage,Trucks,Drag Racing Car,Kit Cars,Salvage Vehicles,Truck Specifications,New General Motors Vehicles,Diesel Trucks,Hot Rods,Gasoline Prices,Armored Cars,Oldsmobile,Campers & RVs,Trucks,Cars,GM,Soccer Scores & Statistics,Geo"
@richcaudle
richcaudle / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
// Include the library
require 'vendor/datasift/datasift-php/lib/datasift.php';
// Create a client
$client = new DataSift_User('YOUR_USERNAME', 'YOUR_APIKEY');
// Declare a filter in CSDL, looking for content mentioning brands, tagging each mentioned
$csdl = 'tag "Calvin Klein" { interaction.content contains "Calvin Klein" }
<?php
// Declare a filter in CSDL, looking for content mentioning brands, tagging each mentioned
$csdl = 'tag.brand "Calvin Klein" { interaction.content contains "Calvin Klein" }
tag.brand "GQ" { interaction.content contains "GQ" }
tag.brand "Adidas" { interaction.content contains "Adidas" }
return
{
interaction.content contains_any "Calvin Klein, GQ, Adidas"
<?php
// Include all dependencies, via Composer
require 'vendor/autoload.php';
// Create a client
$client = new DataSift_User('YOUR_USERNAME', 'YOUR_APIKEY');
?>
<?php
// Declare event handling object for stream consumption
class EventHandler implements DataSift_IStreamConsumerEventHandler
{
public function onInteraction($consumer, $interaction, $hash)
{
echo "INTERACTION: ".json_encode($interaction).PHP_EOL.PHP_EOL;
}
// Triggered when a connection is successfully setup
<?php
// Compiles a stream from a CSDL definition, looking for all mentions of brands
$csdl = 'interaction.content contains_any "Calvin Klein, GQ, Adidas"';
$filter = $client->createDefinition($csdl);
echo "Filter hash: " . $filter->getHash().PHP_EOL;
?>
{
"require": {
"datasift/datasift-php": "*"
}
}
import com.datasift.client.DataSiftClient;
import com.datasift.client.DataSiftConfig;
import com.datasift.client.core.Stream;
import com.datasift.client.stream.*;
public class Main {
public static void main(String[] args) {
// TODO: Enter your username and API key