$ pip install click requests
$ python query_export.py --redash-url "https://app.redash.io/" --api-key ""
| /* Using a JavaScript proxy for a super low code REST client */ | |
| // via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg | |
| // also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3 | |
| // also see https://github.com/fastify/manifetch | |
| // also see https://github.com/flash-oss/allserver | |
| // and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
| const createApi = (url) => { | |
| return new Proxy({}, { | |
| get(target, key) { |
| -- See how long the currrently active txns have been running for | |
| SELECT now()-xact_start, * FROM pg_stat_activity; | |
| -- pg_stat_activity is a very useful table in general | |
| -- eg. you can also see a summary of how many txns are currently running and | |
| -- in what state | |
| SELECT state, count(*) FROM pg_stat_activity GROUP BY state; | |
| -- terminate process | |
| SELECT pg_terminate_backend(pid); |
| # | |
| # Example fluentd config file for nginx access log injection into Google Bigquery | |
| # collecting nginx access log | |
| <source> | |
| @type tail | |
| tag accesslogs-rickts-dev-box | |
| path /var/log/nginx/access.log | |
| format apache | |
| buffer_type file |
| SELECT | |
| SUM(fcp.density) | |
| FROM | |
| `chrome-ux-report.chrome_ux_report.201710`, | |
| UNNEST(first_contentful_paint.histogram.bin) AS fcp | |
| WHERE | |
| origin = "https://www.google.co.in" | |
| AND effective_connection_type.name = "3G" | |
| AND fcp.END <= 1000 |
| import io | |
| import requests | |
| import pandas as pd | |
| from bokeh.models import ColumnDataSource, HoverTool, ResizeTool, SaveTool | |
| from bokeh.models.widgets import TextInput, Button | |
| from bokeh.plotting import figure, curdoc | |
| from bokeh.layouts import row, widgetbox | |
| TICKER = "" |
| // Promise.all is good for executing many promises at once | |
| Promise.all([ | |
| promise1, | |
| promise2 | |
| ]); | |
| // Promise.resolve is good for wrapping synchronous code | |
| Promise.resolve().then(function () { | |
| if (somethingIsNotRight()) { | |
| throw new Error("I will be rejected asynchronously!"); |
The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.
# pulling one User object
user = User.query.get(1)
I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.
What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.
Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.