Skip to content

Instantly share code, notes, and snippets.

@DTAIEB
DTAIEB / sample_code_pixie_debugger_with_PixieApp.py
Last active March 7, 2018 03:01
Shows how PixieDebugger can help debug PixieApps
from pixiedust.display.app import *
@PixieApp
class TestApp():
@route()
def main_screen(self):
return """
<button type="submit" pd_options="badroute=true" pd_target="target{{prefix}}">
Call bad Route
</button>
<div id="target{{prefix}}"></div>
@DTAIEB
DTAIEB / sample_code_pixie_debugger_2.py
Created March 6, 2018 23:05
Invoke PixieDebugger with breakpoints
%%pixie_debugger -b find_max 9
import random
def find_max (values):
max = 0
for val in values:
if val > max:
max = val
return max
find_max(random.sample(range(100), 10))
@DTAIEB
DTAIEB / sample_code_pixie_debugger.py
Created March 6, 2018 18:07
Sample Code for illustrating how the PixieDebugger works
%%pixie_debugger
import random
def find_max (values):
max = 0
for val in values:
if val > max:
max = val
return max
find_max(random.sample(range(100), 10))
<html>
<body>
<object type="text/html" data="https://davidclusterpaid.us-south.containers.mybluemix.net/embed/aaf70254-0069-483e-a641-46062041aac4/600/400" width="600" height="400"><a href="https://davidclusterpaid.us-south.containers.mybluemix.net/embed/aaf70254-0069-483e-a641-46062041aac4">View Chart</a></object>
</body>
</html>
@DTAIEB
DTAIEB / PixieApp Dashboard.py
Created June 5, 2017 02:59
PixieApp dashboard for the Data Science Bootcamp with PixieDust
from pixiedust.display.app import *
from pixiedust.apps.mapboxBase import MapboxBase
@PixieApp
class SFDashboard(MapboxBase):
def setup(self):
self.mapJSONOptions = {
"mapboxtoken": "XXXX",
"chartsize": "90",
"aggregation": "SUM",
@DTAIEB
DTAIEB / runSamplePixieApp.py
Created April 7, 2017 18:17
Run Sample Pixie App
d1 = sqlContext.createDataFrame(
[(2010, 'Camping Equipment', 3, 200),(2010, 'Camping Equipment', 10, 200),(2010, 'Golf Equipment', 1, 240),
(2010, 'Mountaineering Equipment', 1, 348),(2010, 'Outdoor Protection',2,200),(2010, 'Personal Accessories', 2, 200),
(2011, 'Camping Equipment', 4, 489),(2011, 'Golf Equipment', 5, 234),(2011, 'Mountaineering Equipment',2, 123),
(2011, 'Outdoor Protection', 4, 654),(2011, 'Personal Accessories', 2, 234),(2012, 'Camping Equipment', 5, 876),
(2012, 'Golf Equipment', 5, 200),(2012, 'Mountaineering Equipment', 3, 156),(2012, 'Outdoor Protection', 5, 200),
(2012, 'Personal Accessories', 3, 345),(2013, 'Camping Equipment', 8, 987),(2013, 'Golf Equipment', 5, 434),
(2013, 'Mountaineering Equipment', 3, 278),(2013, 'Outdoor Protection', 8, 134),(2013,'Personal Accessories',4, 200)],
["year","zone","unique_customers", "revenue"])
@DTAIEB
DTAIEB / samplePixieApp.py
Last active April 7, 2017 18:10
Sample Pixie App
from pixiedust.display.app import *
@PixieApp
class SamplePixieApp:
def foo(self):
print("Hello from a function defined in the app itself")
@route(clicked="true")
def _clicked(self):
self._addHTMLTemplateString("""<input option_clicked="false" type="button" value="You Clicked, Now Go back">""")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DTAIEB
DTAIEB / cloudantUpsert.js
Created September 1, 2015 14:27
Upsert a document in a cloudant/couch database
/**
* Update doc if exists, insert a new one if not
* @param: docId
* @param: callback(doc), return updated document by the caller
* @param: done( err, doc ) status callback
*/
this.upsert = function( db, docId, callback, done ){
var insert = function( body ){
//Let caller modify doc if already exists, caller can replace with entirely new doc, however, doc id will be reestablished if doc already exists
var id = body && (body._id || body.id);
@DTAIEB
DTAIEB / deleteDocsFromCloudantView.js
Created September 1, 2015 01:25
Delete all documents from a Cloudant view
var async = require("async");
var _ = require("lodash");
function deleteDocsFromView( db, designName, viewName, callback){
async.waterfall([
function( callback ){
db.view(designName, viewName, function(err, data) {
if ( err ){
return callback( err );
}