Skip to content

Instantly share code, notes, and snippets.

View arikfr's full-sized avatar

Arik Fraimovich arikfr

View GitHub Profile
@arikfr
arikfr / overview.md
Created February 29, 2016 13:30
Re:dash Features Overview 29/2/2016

Redash Features Overview

Features

  • Querying (events by date example)
    • Save
    • Fork
    • Refresh schedule
    • Auto complete
  • Schema (updated every 30 minutes)
@arikfr
arikfr / README.md
Last active April 16, 2024 07:53
Redash Query Export Tool

Setup

$ pip install click requests

Usage

$ python query_export.py --redash-url "https://app.redash.io/" --api-key ""
@arikfr
arikfr / exporter.py
Created January 20, 2016 16:30
Re:dash import/export script (import works w/ version 0.9.0, export should be less version sensitive)
import os
import gzip
from tqdm import tqdm
import click
import json
try:
from redash import models
from redash.utils import json_dumps
{
"rows":[
{
"_id":"CA",
"totalPop":29754890
},
{
"_id":"NY",
"totalPop":17990402
}
@arikfr
arikfr / Notes.md
Last active August 29, 2015 14:25
Notes on implementing datasource permissions in re:dash

Each user in the system has one group or more he is member of. These groups are used to assign permissions to this user. I will add the option to set a datasource to belong to one or more groups. This will mean, that a user who is a member of this group, will have access to the datasources that belong to this group.

In technical terms: have a many to many relationship between groups and datasources. And have a calculated property on the User class, that will return the list of data sources he has access to.

Next we need to enforce this restriction:

  1. In the datasources list API call, we will filter out the ones the user don't have access to. Or as an alternative: ask for the ones he has access to, and return only them.
  2. For all queries and query results related API calls, we will check if the current user has access to the given query (based on the data source it belongs to), and if not, won't return it or filter it out from a group of queries.
  3. For all dashboard/widgets/visualization APIs, do the sam
@arikfr
arikfr / query.py
Created May 21, 2015 15:19
re:dash Python datasource join example
# get existing queries results
users = get_query_result(132) # this one has {id, name}
events_by_users = get_query_result(131) # this one has {user_id, events count}
# actual merging. can be replaced with helper function and/or some Pandas code
events_dict = {}
for row in events_by_users['rows']:
events_dict[row['user_id']] = row['count']
for row in users['rows']:
[supervisord]
nodaemon=false
logfile=/opt/redash/logs/supervisord.log
pidfile=/opt/redash/supervisord/supervisord.pid
directory=/opt/redash/current
[inet_http_server]
port = 127.0.0.1:9001
[rpcinterface:supervisor]
@arikfr
arikfr / gist:95f0706a3457fad7489a
Created February 1, 2015 08:16
re:dash nginx site config with sll
upstream redash_servers {
server 127.0.0.1:5000;
}
server {
listen [::]:80;
listen 443 default_server ssl;
# Make sure to set paths to your certificate .pem and .key files.
ssl_certificate /path-to/cert.pem;
@arikfr
arikfr / fabfile.py
Last active February 19, 2021 10:03
re:dash fabfile
#!/usr/bin/env python
# vim: ts=4:sw=4:expandtab:autoindent:
import os
import sys
import requests
import filecmp
from fabric.context_managers import hide, settings, prefix
from fabric.api import sudo, task, run, cd, env
from fabric.contrib.console import confirm
from fabric.colors import green
@arikfr
arikfr / export_lists.py
Created August 19, 2014 04:57
Simple script to export Twitter lists to CSV
import twitter # python-twitter
import csv
import cStringIO
import codecs
from requests_oauthlib import OAuth1Session
REQUEST_TOKEN_URL = 'https://api.twitter.com/oauth/request_token'
ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
AUTHORIZATION_URL = 'https://api.twitter.com/oauth/authorize'
SIGNIN_URL = 'https://api.twitter.com/oauth/authenticate'