Skip to content

Instantly share code, notes, and snippets.

View susodapop's full-sized avatar

Jesse susodapop

View GitHub Profile
@susodapop
susodapop / sample_data.json
Created July 2, 2022 20:48
Used for example on discuss.redash.io
{
"table": {
"columnNames": ["time", "Temperature"],
"columnTypes": ["String", "float"],
"columnUnits": ["UTC", null],
"rows": [
["2022-06-25T00:00:00Z", 21.8],
["2022-06-25T00:06:00Z", 21.5],
["2022-06-25T00:12:00Z", 21.2],
["2022-06-25T00:18:00Z", 21],
atsd-client==3.0.5
- python-dateutil [required: Any, installed: 2.8.0]
- six [required: >=1.5, installed: 1.16.0]
- requests [required: >=2.12.1, installed: 2.21.0]
- certifi [required: >=2017.4.17, installed: 2021.5.30]
- chardet [required: >=3.0.2,<3.1.0, installed: 3.0.4]
- idna [required: >=2.5,<2.9, installed: 2.8]
- urllib3 [required: >=1.21.1,<1.25, installed: 1.24.3]
- tzlocal [required: Any, installed: 3.0]
- backports.zoneinfo [required: Any, installed: 0.2.1]
"""
Author: Jesse Whitehouse
I used mkdocs to write static documentation for my Flask web application.
I write the docs in markdown and run `mkdocks build`, which outputs a full
static website into the /site directory.
In production, my webserver servers /site statically. But in development
mode I want to still see the docs for testing purposes. So I wrote this
View.
@susodapop
susodapop / redash_create_and_run_query.py
Last active April 5, 2021 22:37
Simple example of creating a query and fetching its results with app.redash.io
import json, time
from redash_toolbelt import Redash
URL = "https://app.redash.io/<org slug>"
KEY = "<your api key>"
DS_ID = 1234 # enter an integer data source ID here
client = Redash(URL, KEY)
# new queries need query text, a name, and a target data source id

Redash SSH Tunnel API

SaaS Redash traffic always arrives from our public IP address: 52.71.84.157. We recommend directly whitelisting this address through your firewall. Alternatively, you can set up an SSH tunnel using the API described below.

Overview

# This query runner is licensed under the BSD 2-Clause "Simplified" License
#
# Copyright (c) 2013-2021, Arik Fraimovich.
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 22 columns, instead of 1. in line 4.
Year,Population1,"Violentcrime2","Violent crime rate ","Murder andnonnegligent manslaughter","Murder and nonnegligent manslaughter rate ","Rape(revised definition3)","Rape(revised definition) rate3","Rape(legacy definition4)","Rape(legacy definition) rate4",Robbery,"Robbery rate ","Aggravated assault","Aggravated assault rate ","Property crime","Property crime rate ",Burglary,"Burglary rate ","Larceny-theft","Larceny-theft rate ","Motor vehicle theft","Motor vehicle theft rate "
1997,"267,783,607","1,636,096",611.0,"18,208",6.8,,,"96,153",35.9,"498,534",186.2,"1,023,201",382.1,"11,558,475","4,316.3","2,460,526",918.8,"7,743,760","2,891.8","1,354,189",505.7
1998,"270,248,003","1,533,887",567.6,"16,974",6.3,,,"93,144",34.5,"447,186",165.5,"976,583",361.4,"10,951,827","4,052.5","2,332,735",863.2,"7,376,311","2,729.5","1,242,781",459.9
1999,"272,690,813","1,426,044",523.0,"15,522",5.7,,,"89,411",32.8,"409,371",150.1,"911,740",334.3,"10,208,334","3,743.6","2,100,739",770.4,"6,955,520","2,550.7","1,152,075",422.5
2
{
"data": [
{
"cost": "$51.00",
"vendor_account_identifier": "9999-9999-9999",
"vendor_account_name": "acct1"
},
{
"cost": "$50.00",
"vendor_account_identifier": "9999-9999-9998",
@susodapop
susodapop / quick_date_ranges.py
Last active December 2, 2020 23:34 — forked from arikfr/trigger_refresh.py
Trigger refresh of Redash queries based on query tag
from datetime import datetime, timedelta
from collections import namedtuple
def get_frontend_vals():
ranges = calculate_ranges()
singles = calculate_singletons()
valkeys = [k for k in ranges.keys()] + [k for k in singles.keys()]
from datetime import datetime, timedelta
from collections import namedtuple
def get_frontend_vals():
ranges = calculate_ranges()
singles = calculate_singletons()
valkeys = [k for k in ranges.keys()] + [k for k in singles.keys()]