Skip to content

Instantly share code, notes, and snippets.

View jnu's full-sized avatar
🤠

Joe Nudell jnu

🤠
View GitHub Profile
@jnu
jnu / powerbi_query.py
Last active August 18, 2025 07:06
Interpretting PowerBI query API responses
"""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.
@jnu
jnu / usps_custom_bounds.sh
Created March 15, 2023 19:44
Example USPS custom bounds request
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.
@jnu
jnu / app.py
Last active February 15, 2023 19:00
Shared cache with gunicorn `--preload`
from multiprocessing import Manager
import os
from flask import Flask
app = Flask(__name__)
# This line prints one single time when `--preload` is used:
@jnu
jnu / pupauth.js
Created July 23, 2018 16:49
puppeteer basic scraping harness with auth
const puppeteer = require('puppeteer');
const commander = require('commander');
const fs = require('mz/fs');
// Constants ------------------------------------------------------------------
/**
* Entry URL of site to scrape.
@jnu
jnu / num_words_to_int.py
Created May 8, 2018 06:22
parse number words as integer
# 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,
/**
* @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'
@jnu
jnu / scan.js
Last active February 17, 2016 05:48
/**
* 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';
// ./a.js
// Default export
export default function myFn() {
/* ... */
}
// optionally include additional exports:
export const FOO = 'foo';
// 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);
@jnu
jnu / gist:42d62562534d9bcbcdef
Last active August 29, 2015 14:08
Mounting React Component in Backbone View, passing data back and forth
// 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() {