This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""PowerBI JSON query API parsing | |
These are my rough notes for pulling data from PowerBI JSON queries. | |
I sketched this out after working with a query that joined two data sources | |
and returned tabular data. | |
There are two sections in the code below: | |
1) A rough typing of the API response. | |
It's not at all complete and probably has some mistakes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl 'https://usps.biglocalnews.org/api/sample' -X POST -H 'Content-Type: application/json' --data-raw '{"custom_bounds":{"type":"Polygon","coordinates":[[[-72.36838584940675,44.59285546915079],[-72.37112518348312,44.593344554744526],[-72.37459222226431,44.59462181389889],[-72.37915444020688,44.596257313279494],[-72.39051656263938,44.60038756242316],[-72.40441939526487,44.60547626549913],[-72.41950188199566,44.61098554480214],[-72.43447124481686,44.61643588693947],[-72.44911512810113,44.62177891617394],[-72.45815134995946,44.625050210329704],[-72.46263357512018,44.62674263205467],[-72.46844924201595,44.62888881502578],[-72.4757322116334,44.631516391179794],[-72.48279415530985,44.63411233129938],[-72.48740486332211,44.62753350311244],[-72.48916178540512,44.625006696516635],[-72.48983602674814,44.6238873425821],[-72.49259891809365,44.620131359078215],[-72.49569741126957,44.615617401961984],[-72.49956027851513,44.60992193909056],[-72.50601231917516,44.60071021479175],[-72.51321216242664,44.590334327964285],[-72. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Manager | |
import os | |
from flask import Flask | |
app = Flask(__name__) | |
# This line prints one single time when `--preload` is used: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const commander = require('commander'); | |
const fs = require('mz/fs'); | |
// Constants ------------------------------------------------------------------ | |
/** | |
* Entry URL of site to scrape. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Map from string versions of integers to ints. | |
_STR_UNIT_TO_INT = { | |
'ZERO': 0, | |
'ONE': 1, | |
'TWO': 2, | |
'THREE': 3, | |
'FOUR': 4, | |
'FIVE': 5, | |
'SIX': 6, | |
'SEVEN': 7, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileOverview Deep object merging and cloning | |
*/ | |
/** | |
* Get a non-ridiculous type of an object. All of the normal JS types of | |
* primitives are returned, but more specificity is added in cases where | |
* `typeof foo === 'object'`. In particular: | |
* | |
* betterType(null) === 'null' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Scan a string for all characters in code range. Logs the first | |
* index of all matched characters. Useful for debugging illegal | |
* hidden characters. | |
* @param {string} str - string to scan | |
* @param {number} fromCode - Unicode code point to start search at | |
* @param {number} toCode - Unicode code point to end search at | |
*/ | |
function scan(str, fromCode, toCode) { | |
'use strict'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./a.js | |
// Default export | |
export default function myFn() { | |
/* ... */ | |
} | |
// optionally include additional exports: | |
export const FOO = 'foo'; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// worker.js | |
var store = {}; | |
function getVal(key) { | |
let val; | |
if (store.hasOwnProperty(key)) { | |
val = store[key]; | |
} else { | |
val = store[key] = Math.round(Math.random() * 100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// React component with a text input and a save button | |
var MyReactComponent = React.createClass({ | |
propTypes: { | |
onSave: React.PropTypes.func.isRequired, | |
value: React.PropTypes.string | |
}, | |
getDefaultProps: function() { |