Skip to content

Instantly share code, notes, and snippets.

Arik Fraimovich arikfr

Block or report user

Report or block arikfr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
arikfr / get-query-result.js
Created Aug 18, 2019
Query Redash's API for fresh results from Javascript
View get-query-result.js
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
async function getQueryResult(slug, queryId, apiKey, options = {}) {
const instance = axios.create({
baseURL: `${slug}`,
headers: {
Authorization: `Key ${apiKey}`
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 / example.rb
Last active Mar 15, 2019
Example of for using Redash API in Ruby to update the schedule
View example.rb
require 'httparty'
class Redash
include HTTParty
def initialize(slug, api_key)
@base_uri = "{slug}"
@headers = {
'Authorization': "Key #{api_key}"
arikfr /
Last active Oct 21, 2019
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 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 / saas_metrics.sql
Last active Jun 21, 2019
SaaS Metrics Query
View saas_metrics.sql
Explanation of what's going on in this query can be found in this blog post:
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 /
Created Sep 11, 2017
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)}
View dynamodb_readonly.json
"Version": "2012-10-17",
"Statement": [
"Action": [
arikfr /
Created Apr 24, 2017
Redash Refresh API usage example with parameters Raw
import os
import requests
import time
from pprint import pprint
def poll_job(s, redash_url, job):
# TODO: add timeout
while job['status'] not in (3,4):
response = s.get('{}/api/jobs/{}'.format(redash_url, job['id']))
arikfr / countries.json
Last active Feb 12, 2017
Countries Data
View countries.json
{"rows": [{"code": "BD", "continent": "AS", "name": "Bangladesh"}, {"code": "BE", "continent": "EU", "name": "Belgium"}, {"code": "BF", "continent": "AF", "name": "Burkina Faso"}, {"code": "BG", "continent": "EU", "name": "Bulgaria"}, {"code": "BA", "continent": "EU", "name": "Bosnia and Herzegovina"}, {"code": "BB", "continent": "NA", "name": "Barbados"}, {"code": "WF", "continent": "OC", "name": "Wallis and Futuna"}, {"code": "BL", "continent": "NA", "name": "Saint Barthelemy"}, {"code": "BM", "continent": "NA", "name": "Bermuda"}, {"code": "BN", "continent": "AS", "name": "Brunei"}, {"code": "BO", "continent": "SA", "name": "Bolivia"}, {"code": "BH", "continent": "AS", "name": "Bahrain"}, {"code": "BI", "continent": "AF", "name": "Burundi"}, {"code": "BJ", "continent": "AF", "name": "Benin"}, {"code": "BT", "continent": "AS", "name": "Bhutan"}, {"code": "JM", "continent": "NA", "name": "Jamaica"}, {"code": "BV", "continent": "AN", "name": "Bouvet Island"}, {"code": "BW", "continent": "AF", "name": "Botswan
You can’t perform that action at this time.