Skip to content

Instantly share code, notes, and snippets.

@refactornator
refactornator / Zoomdata CURL Upload API Example.bash
Last active December 11, 2015 10:29
An example of how to upload data to the Zoomdata Upload API. Send an HTTP POST to your Zoomdata Server that contains a JSON object in the request body.
curl -v --user username:password 'https://localhost:8443/zoomdata/service/upload?source=API%20Test' \
-X POST \
-H 'Content-Type: application/json' \
-d '{"product":"widget", "price":"19.95", "quantity":10}' \
--insecure
@refactornator
refactornator / Zoomdata Python Upload API Example.py
Last active December 11, 2015 10:38
An example of how to upload data to the Zoomdata Upload API. Send an HTTP POST to your Zoomdata Server that contains a JSON object in the request body. Dependencies: requests - http://docs.python-requests.org/en/latest/
import requests, json
headers = {'Content-type': 'application/json'}
params = {'source':'API Test'}
data = {"product":"widget", "price":"19.95", "quantity":10}
url = "https://localhost:8443/zoomdata/service/upload"
r = requests.post(url, data=json.dumps(data), headers=headers, params=params, auth=('username', 'password'), verify=False)
@refactornator
refactornator / gist:4752122
Created February 11, 2013 02:50
Craigslist Blocks Google App Engine
import requests
r = requests.get('http://craigslist.com')
print r.status_code #200 is printed because Craigslist has no idea who you are
r = requests.get('http://craigslist.com', headers={'User-Agent': 'AppEngine-Google'})
print r.status_code #404 is printed because Craigslist doesn't like you
@refactornator
refactornator / MyData.csv
Last active January 17, 2021 11:04
Upload a CSV file in the body of a HTTP POST request.
product price quantity
widget1 19.95 10
widget2 24.00 20
widget1 12.00 40
@refactornator
refactornator / trend.js
Created May 23, 2013 03:21
Zoomdata Trend Line A simple example of a trendline that works in Zoomdata. Just copy and paste this code into a new file in the Zoomdata Visualization Studio and press preview. Based on this example by Mike Bostock http://bost.ocks.org/mike/path/. #Zoomdata
// ©2013 Zoomdata, Inc. All Rights Reserved.
$(document).ready( function() {
$("#timeControls").hide();
$("head").append("<style>");
css = $("head").children(":last");
css.attr({
type: "text/css"
});
cssString = '.axis path, .axis line {' +
@refactornator
refactornator / dashboard.js
Created May 23, 2013 03:23
Zoomdata Dashboard Example A simple dashboard that uses the Packery JS library for draggable layout. Just create a new visualization and add a new file for each of the files in this gist. Then, preview the 'Real Time Sales' data. #Zoomdata
// ©2013 Zoomdata, Inc. All Rights Reserved.
CurrentVisualizationController = (function (){
var Datum = Backbone.Model.extend({
defaults: {
}
});
var Graph = Backbone.Collection.extend({
@refactornator
refactornator / text.js
Created August 14, 2013 14:48
Zoomdata sample visualization illustrating the JS client API.
// Set up initial code for visualization
var svg = d3.select(controller.element).append("svg")
.attr("width", "100%").attr("height", "100%")
.append("g")
.attr("transform", "translate(10,10)");
// This function receives a JS Array of JS Objects
// representing the current state of your data.
controller.update = function (data) {
// Join new data with old elements, if any.
<!DOCTYPE html>
<meta charset="utf-8">
<style>
html {
-webkit-user-select: none; /* Chrome all / Safari all */
-moz-user-select: none; /* Firefox all */
-ms-user-select: none; /* IE 10+ */
/* No support for these yet, use at own risk */
-o-user-select: none;
@refactornator
refactornator / Resize.js
Last active September 9, 2015 22:08
Zoomdata Javascript SDK Resize Example
/*
* This example illustrates listening to the window resize event and triggering a visualization to be resized.
*/
var visualization,
el = document.getElementById('visualization');
var zoomdataClient = new ZoomdataClient({
apiKey: 'YOUR API KEY',
host: 'localhost:8080/zoomdata',
@refactornator
refactornator / react-joyride - index.d.ts
Last active August 7, 2020 07:43
A workaround type declaration for react-joyride until 2.0 is release and the type definition is updated. Uninstall @types/react-joyride and place this file in @types/react-joyride/index.d.ts
declare module 'react-joyride' {
import * as React from "react";
export default class Joyride extends React.Component<Props, State> {
constructor(props: Props);
reset(restart?: boolean): void;
next(): void;
back(): void;
addTooltip(data: Step): void;