Skip to content

Instantly share code, notes, and snippets.

@DavidWells
DavidWells / javascript-proxy-as-rest-client.js
Last active May 12, 2024 14:24
Using a javascript proxy as low code REST client
/* 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) {
@akaashanky
akaashanky / pg_admin_queries.sql
Last active July 29, 2024 07:34
A few useful queries for Postgres admins
-- 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
@RatulSaha
RatulSaha / 3G-fraction-1s-example.sql
Last active April 27, 2019 17:43
Chrome User Experience Report Analyzed with Google BigQuery
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
@zduey
zduey / iex.py
Created March 4, 2017 16:04
Simple Real-Time Stock Streaming with Bokeh
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 = ""
@arikfr
arikfr / README.md
Last active August 26, 2024 19:27
Redash Query Export Tool

Setup

$ pip install click requests

Usage

$ python query_export.py --redash-url "https://app.redash.io/" --api-key ""
@nolanlawson
nolanlawson / protips.js
Last active August 22, 2024 14:19
Promise protips - stuff I wish I had known when I started with Promises
// 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!");
@typehorror
typehorror / Flask-SQLAlchemy Caching.md
Last active February 15, 2024 14:44
Flask SQLAlchemy Caching

Flask-SQLAlchemy Caching

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.

Usage

retrieve one object

# pulling one User object

user = User.query.get(1)

@tristanfisher
tristanfisher / Ansible-Vault how-to.md
Last active June 11, 2024 13:23
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

Working with ansible-vault


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.