Skip to content

Instantly share code, notes, and snippets.

View arikfr's full-sized avatar

Arik Fraimovich arikfr

View GitHub Profile
@arikfr
arikfr / index.js
Created March 10, 2020 18:56
Changelog generator
const Octokit = require("@octokit/rest");
const createCsvWriter = require("csv-writer").createObjectCsvWriter;
const octokit = new Octokit({
auth: "token " + process.env.GITHUB_TOKEN
});
async function getCommits(since) {
const options = octokit.repos.listCommits.endpoint.merge({
owner: "getredash",
repo: "redash",
@arikfr
arikfr / trigger_refresh.py
Last active December 20, 2019 16:49
Trigger refresh of Redash queries based on query tag
from urllib.parse import urljoin
import requests
import click
import json
class Redash:
def __init__(self, host, api_key):
self.host = host
self.api_key = api_key
@arikfr
arikfr / get-query-result.js
Created August 18, 2019 11:14
Query Redash's API for fresh results from Javascript
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function getQueryResult(slug, queryId, apiKey, options = {}) {
const instance = axios.create({
baseURL: `https://app.redash.io/${slug}`,
headers: {
Authorization: `Key ${apiKey}`
}
@arikfr
arikfr / redash.py
Last active December 11, 2019 04:57
import requests
import os
class Redash(object):
def __init__(self, redash_url, api_key):
self.redash_url = redash_url
self.session = requests.Session()
self.session.headers.update({'Authorization': 'Key {}'.format(api_key)})
def test_credentials(self):
@arikfr
arikfr / example.rb
Last active March 15, 2019 18:10
Example of for using Redash API in Ruby to update the schedule
require 'httparty'
class Redash
include HTTParty
def initialize(slug, api_key)
@base_uri = "https://app.redash.io/#{slug}"
@headers = {
'Authorization': "Key #{api_key}"
}
@arikfr
arikfr / README.md
Last active August 29, 2024 05:28
Setting up HTTPS with LetsEncrypt for Redash Docker Deployment
  1. Make sure the domain you picked points at the IP of your Redash server.
  2. Switch to the root user (sudo su).
  3. Create a folder named nginx in /opt/redash.
  4. Create in the nginx folder two additional folders: certs and certs-data.
  5. Create the file /opt/redash/nginx/nginx.conf and place the following in it: (replace example.redashapp.com with your domain name)
    upstream redash {
        server redash:5000;
    }
    
#!/bin/env python
import sys
import re
import subprocess
def get_change_log(previous_sha):
args = ['git', '--no-pager', 'log', '--merges', '--grep', 'Merge pull request', '--pretty=format:"%h|%s|%b|%p"', 'master...{}'.format(previous_sha)]
log = subprocess.check_output(args)
changes = []
@arikfr
arikfr / saas_metrics.sql
Last active February 20, 2022 14:57
SaaS Metrics Query
/*
Explanation of what's going on in this query can be found in this blog post: https://blog.redash.io/sql-query-to-calculate-saas-metrics-dd25d72a0521.
*/
WITH v_charges AS (
SELECT org_id,
date_trunc('month', start_date) AS month,
coalesce((extra::json->>'amount')::float, (extra::json->>'charged_amount')::integer/100) as total
FROM charges
WHERE extra::json->>'months' = '1'
@arikfr
arikfr / example.py
Created September 11, 2017 07:31
Redash API usage example
import requests
class Redash(object):
def __init__(self, redash_url, api_key):
self.redash_url = redash_url
if not self.redash_url.endswith('/'):
self.redash_url = '{}/'.format(self.redash_url)
self.auth_headers = {'Authorization': 'Key {}'.format(api_key)}
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"dynamodb:BatchGetItem",
"dynamodb:DescribeTable",
"dynamodb:GetItem",
"dynamodb:ListTables",
"dynamodb:Query",