Skip to content

Instantly share code, notes, and snippets.

View arikfr's full-sized avatar

Arik Fraimovich arikfr

View GitHub Profile
@arikfr
arikfr / .env
Last active August 29, 2015 13:56
Example configuration for re:dash
export REDASH_CONNECTION_ADAPTER=pg
export REDASH_CONNECTION_STRING="dbname=ubuntu"
export REDASH_STATIC_ASSETS_PATH="../rd_ui/dist/"
export REDASH_LOG_LEVEL="INFO"
export REDASH_WORKERS_COUNT=6
export REDASH_REDIS_URL=redis://localhost:6379/
export REDASH_DATABASE_URL="postgresql://ubuntu"
export REDASH_COOKIE_SECRET=
export REDASH_ADMINS=
export REDASH_GOOGLE_APPS_DOMAIN=
@arikfr
arikfr / gist:11362378
Last active August 29, 2015 14:00
Kata: Number to LCD
## Goal: write a program that displays LCD style numbers.
### Part 1
Write a program that given a number (with arbitrary number of digits), converts it into LCD style numbers using the following format:
_ _ _ _ _ _ _
| _| _||_||_ |_ ||_||_|
||_ _| | _||_| ||_| _|
@arikfr
arikfr / .env
Last active August 29, 2015 14:00
Configuration files for redash-starter
export REDASH_CONNECTION_ADAPTER=pg
export REDASH_CONNECTION_STRING="dbname=redash"
export REDASH_STATIC_ASSETS_PATH="../rd_ui/dist/"
export REDASH_LOG_LEVEL="INFO"
export REDASH_WORKERS_COUNT=6
export REDASH_REDIS_URL=redis://localhost:6379/1
export REDASH_DATABASE_URL="postgresql://redash"
export REDASH_COOKIE_SECRET=veryverysecret
export REDASH_GOOGLE_APPS_DOMAIN=
@arikfr
arikfr / .env
Last active August 29, 2015 14:01
re:dash development vagrant box provision script
export REDASH_CONNECTION_ADAPTER=pg
export REDASH_CONNECTION_STRING="dbname=redash"
export REDASH_STATIC_ASSETS_PATH="../rd_ui/app/"
export REDASH_LOG_LEVEL="INFO"
export REDASH_WORKERS_COUNT=6
export REDASH_REDIS_URL=redis://localhost:6379/1
export REDASH_DATABASE_URL="postgresql://redash"
export REDASH_COOKIE_SECRET=veryverysecret
export REDASH_GOOGLE_APPS_DOMAIN=
@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;
[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 / 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
{
"rows":[
{
"_id":"CA",
"totalPop":29754890
},
{
"_id":"NY",
"totalPop":17990402
}
import Skype4Py
skype = Skype4Py.Skype()
skype.Attach()
number = '+972...'
sms = skype.CreateSms(Skype4Py.smsMessageTypeOutgoing, number)
sms.Body = 'Test SMS from Python!'
sms.Send()
@arikfr
arikfr / gist:110940
Created May 13, 2009 08:53
Teapot the PHP version
/*
See: http://www.arikfr.com/blog/how-to-create-a-teapot-with-php.html for more details.
Thanks to @toolmantim for the inspiration (http://toolmantim.com/articles/im_a_little_teapot)
*/
$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'BREW') {
header("HTTP/1.1 418 I'm a teapot");
die("We do serve ICE Tea, though.\n");