Skip to content

Instantly share code, notes, and snippets.

View arikfr's full-sized avatar

Arik Fraimovich arikfr

View GitHub Profile
@arikfr
arikfr / refresh.py
Last active February 1, 2023 11:24
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
arikfr / countries.json
Last active February 12, 2017 12:01
Countries Data
{"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
@arikfr
arikfr / cohort.sql
Created October 19, 2016 12:43
Cohort Query Example
with
time_frame as (
select current_date - 14
),
population as (
select created_at::date as cohort_date, id as unique_id
from organizations
where created_at > (select * from time_frame)
@arikfr
arikfr / keybase.md
Created October 18, 2016 08:58
Keybase Proof

Keybase proof

I hereby claim:

  • I am arikfr on github.
  • I am arikfr (https://keybase.io/arikfr) on keybase.
  • I have a public key ASBNUSKY0adYMAYhkO4QmrqOdjIuV4DtSAtiPsuyb6ZjIgo

To claim this, I am signing this object:

@arikfr
arikfr / dashboard_editor.py
Created September 22, 2016 06:21
Dashboard layout editor
import os
import sys
import requests
import json
import time
REDASH_HOST = os.environ.get('REDASH_HOST', 'https://app.redash.io/account')
API_KEY = '...'
@arikfr
arikfr / poll.py
Last active August 2, 2016 13:53
Redash Polling Example
import os
import requests
import time
from pprint import pprint
REDASH_HOST = os.environ.get('REDASH_HOST', 'https://demo.redash.io')
def poll_job(s, job):
# TODO: add timeout
while job['status'] not in (3,4):
@arikfr
arikfr / refresh_example.py
Created July 22, 2016 11:40
Example code of how to use Redash refresh API
REDASH_HOST = os.environ.get('REDASH_HOST', 'https://app.redash.io/name')
def poll_job(s, job):
# TODO: timeout
while job['status'] not in (3,4):
response = s.get('{}/api/jobs/{}'.format(REDASH_HOST, job['id']))
job = response.json()['job']
time.sleep(1)
return job['status'] == 3
@arikfr
arikfr / promises_caching.js
Created July 13, 2016 10:28
Promises Caching
var inProgressUrls = {};
function grabScreenshot(url) {
var inProgress = inProgressUrls[url];
if (inProgress) {
return inProgress;
}
var promise = new Promise(function(fulfill, reject) {
... grab screenshot ...
var page = require('webpage').create(),
system = require('system'),
address, output, size;
if (system.args.length < 3 || system.args.length > 5) {
console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
console.log(' image (png/jpg output) examples: "1920px" entire page, window width 1920px');
console.log(' "800px*600px" window, clipped to 800x600');
phantom.exit(1);
{
"columns": [
{
"name": "action",
"type": null,
"friendly_name": "action"
},
{
"name": "count",
"type": "integer",