Skip to content

Instantly share code, notes, and snippets.

View antichaos's full-sized avatar

Johan de Groot antichaos

View GitHub Profile
@antichaos
antichaos / tableau2csv.py
Last active July 25, 2023 09:32
Tableau2csv
import tableauserverclient as TSC
import os
import argparse
import logging
# set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s', filename='tableau2csv.log')
logger = logging.getLogger(__name__)
# set up argument parser
{"ts":"2022-10-31T10:01:05.860823","pid":40503,"tid":"318df1000","sev":"info","req":"3","sess":"pd29g2fASvK9yikO2lCjDA","ctx":{"req":"-","site":"-","user":"-","host":"Eddie","workload":"interactive"},"k":"query-begin","v":{"spooling":false,"query-settings-active":false,"query-hash":"025a.3898559fb452.000000","query":"CREATE DATABASE \"/Volumes/T7/tmp/knmi_daggegevens_daggegevens+ (agrajag).hyper\""}}
{"ts":"2022-10-31T10:01:05.860971","pid":40503,"tid":"31433a000","sev":"info","req":"3","sess":"pd29g2fASvK9yikO2lCjDA","k":"query-running","v":{"worker-slot":7}}
{"ts":"2022-10-31T10:01:05.861527","pid":40503,"tid":"31433a000","sev":"info","req":"-","sess":"-","k":"transient-resource-create","v":{"storage-id":{"provider":"transient","path":"sessionDB_pd29g2fASvK9yikO2lCjDA"},"elapsed-create-tempfile":0.00021175,"temp-path":"/private/var/folders/cp/3kpxz2ws6jd1lsy3p6t_k72m0000gn/T/tableau-temp/hyper_40490_1tn72ho12n7n671fqgodt0exsbon/hyper_transient.40503.1.tmp","elapsed-do-create":0.000157125,"elapsed":0.0003709
@antichaos
antichaos / lc-tableau.html
Created September 28, 2022 15:26
LC embed code
<div class='tableauPlaceholder' id='viz1664378640267' style='position: relative'><noscript><a href='#'><img alt='view ' src='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;AC&#47;ACLEDrangeselector&#47;view&#47;1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='embed_code_version' value='3' /> <param name='site_root' value='' /><param name='name' value='ACLEDrangeselector&#47;view' /><param name='tabs' value='no' /><param name='toolbar' value='yes' /><param name='static_image' value='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;AC&#47;ACLEDrangeselector&#47;view&#47;1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /><param name='language' value='en-US' /><param name='fi
@antichaos
antichaos / embed-error.html
Created July 4, 2022 13:29
Tableau embed - gives error
<html lang="en">
<head>
<script type="module" src="https://public.tableau.com/javascripts/api/tableau.embedding.3.latest.min.js"></script>
<title></title>
</head>
<body>
<button onclick="filterState()">filter</button>
<button onclick="clearState()">clear</button>
<button onclick="unDo()">undo</button>
import tableauserverclient as TSC
import re
tableau_auth = TSC.PersonalAccessTokenAuth('TOKENNAME','TOKENVALUE')
server = TSC.Server('TABLEAUSERVER', use_server_version=True)
with server.auth.sign_in(tableau_auth):
for workbook in TSC.Pager(server.workbooks):
@antichaos
antichaos / tableau.sql
Last active December 29, 2020 13:37
Postgres/PostGIS query for buffer and spatial 'shifted' point
CAST(
-- make collection
st_collect(ARRAY[
-- make line from two range polygons
st_difference( CAST(
st_buffer(
CAST(
ST_MakePoint(
"postinfo"."lon",
@antichaos
antichaos / python-alteryx-5.py
Created October 4, 2020 07:50
python-alteryx-5.py
indicators = ['NY.GDP.MKTP.CD' # GDP (current US$)
'SP.POP.TOTL', # Population, total
'SE.PRM.ENRR', # School enrollment, primary (% gross)
'EN.ATM.CO2E.PC', # CO2 emissions (metric tons per capita)
'SI.POV.NAHC', # Poverty headcount ratio at national poverty lines (% of population)
'SP.DYN.LE00.IN', # Life expectancy at birth, total (years)
'SI.POV.NAHC', # Poverty headcount ratio at national poverty lines (% of population)
'NY.GNP.PCAP.CD', # GNI per capita, Atlas method (current US$)
'IQ.SCI.OVRL', # Statistical Capacity score (Overall average)
'SI.POV.URHC', # Urban poverty headcount ratio at national poverty lines (% of urban population)
SELECT
'CyberSecurityIndex' AS "index",
"CyberSecurityIndex"."Country" AS "Country",
"CyberSecurityIndex"."iso3" AS "iso3",
CAST("CyberSecurityIndex"."Year" AS TEXT) AS "Year",
t.subindex AS subindex,
CAST(t.value AS float) AS value
FROM "indices"."009_cybersecurityindex" "CyberSecurityIndex"
cross join lateral (
values
@echo off
# Create date-timestamp to use in backup-filenames
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set DateTime=%%a
set Yr=%DateTime:~0,4%
set Mon=%DateTime:~4,2%
set Day=%DateTime:~6,2%
set Hr=%DateTime:~8,2%
set Min=%DateTime:~10,2%
set Sec=%DateTime:~12,2%
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
</head>
<body>
<script>