Skip to content

Instantly share code, notes, and snippets.

View aloth's full-sized avatar

Alexander Loth aloth

View GitHub Profile
@aloth
aloth / tc17_03_url_unshorten.txt
Created July 24, 2017 12:49
Unshorten URLs in Tableau with R
SCRIPT_STR('
newurl <- .arg1
url <- ""
while(url != newurl){
data <- system(toString(paste0("curl -I ", newurl)), intern=T)
if(sum(grepl("location: ", tolower(data))) == 0){
url <- newurl
}else{
data <- subset(data, tolower(substring(data, 1, 9))=="location:")
stringurl <- substring(data[1], 11, nchar(data[1])-1)
@aloth
aloth / tc17_julia_tableau_sphere.txt
Created September 19, 2017 08:53
Calling Julia code from Tableau via R
SCRIPT_INT('
library(XRJulia)
if (!exists("ev")) ev <- RJulia()
y <- juliaEval("
4 / 3 * %s * ' + STR([Factor]) + ' * pi ^ 3
", .arg1)
',
[Radius])
@aloth
aloth / wheezy-backports-raspbian.sh
Created July 23, 2018 19:17
Debian Backports for Raspbian Wheezy (works on ARMv7 devices: Pi 2 and newer)
echo "deb http://ftp.fr.debian.org/debian/ wheezy-backports main contrib non-free" | sudo sh -c 'cat >> /etc/apt/sources.list'
echo "deb-src http://ftp.fr.debian.org/debian/ wheezy-backports main" | sudo sh -c 'cat >> /etc/apt/sources.list'
gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010
gpg -a --export 7638D0442B90D010 | sudo apt-key add -
sudo apt-get update
SCRIPT_STR("
import http.client, urllib, base64, json
YOUR_API_KEY = 'xxx'
name = _arg1[0]
company = _arg2[0]
try:
headers = {'Ocp-Apim-Subscription-Key': YOUR_API_KEY }
params = urllib.urlencode({'q': name + ' ' + company + ' linkedin','count': '3'})
connection = http.client.HTTPSConnection('api.cognitive.microsoft.com')
connection.request('GET', '/bing/v7.0/search?%s' % params, '{body}', headers)