Skip to content

Instantly share code, notes, and snippets.

View pualien's full-sized avatar
🎯
Focusing

Matteo Senardi pualien

🎯
Focusing
View GitHub Profile
@pualien
pualien / get_track_uri_from_playlist.py
Last active August 9, 2020 19:23
List of spotify uri from given playlist URI
import os
import requests
PLAYLIST_URI = os.environ['PLAYLIST_URI']
SPOTIFY_TOKEN = os.environ['SPOTIFY_TOKEN'] # from default api login or more easily from chrome network inspecting calls directed to api.spotify.com
url = "https://api.spotify.com/v1/playlists/{}".format(PLAYLIST_URI)
querystring = {"type": "track,episode", "market": "from_token"}
headers = {
@pualien
pualien / simple_slack_vanilla.js
Last active February 27, 2020 15:36
Simple methods to send javascript obejects to slack webhook
let js_obj = {a:'test_track', b:2};
function __getSlackFields(data){
var fields = [];
Object.keys(data).map((key) => {
fields.push({ title: key, value: data[key], short: true });
return key;
});
return fields;
}
@pualien
pualien / traffic_data_sources.js
Created November 8, 2019 16:10
JS to retrieve Traffic Data Sources without Google Analytics Cookies
var __firstSessionCookieName = '$$FIRST_SESSION_COOKIE_NAME$$';
var __returningSessionCookieName = '$$RETURNING_SESSION_COOKIE_NAME$$';
var __cookieExpiration = '$$COOKIE_GMT_EXPIRATION$$';
var __reviveFirstSession = true; //Revive first session and avoids saving returning session
var __customCampaignParam = '$$CUSTOM_CAMPAIGN_QUERY_PARAM$$';
function __crumbleCookie(a) {
for (var d = document.cookie.split(";"), c = {}, b = 0; b < d.length; b++) {
var e = d[b].substring(0, d[b].indexOf("=")).trim();
@pualien
pualien / iframe.js
Created December 12, 2019 11:49
Iframe Post Message cmp IAB
/* iframe code */
var callId = Math.random();
function __receiveTealiumMessage(event) {
var tealiumMasterTagCallIdentifier = '__rtiShareDl';
var event_data = {};
try {
event_data = JSON.parse(event.data);
} catch (e) {
@pualien
pualien / install_spark_gcs.sh
Created April 13, 2021 06:41
Install Spark/Pyspark 3.1.1 with Google Cloud Storage Connector
#!/bin/bash
export CUSTOM_SPARK_VERSION="3.1.1"
export CUSTOM_PYSPARK_VERSION="3.1.1"
export CUSTOM_HADOOP_VERSION="3.2"
export CUSTOM_HADOOP_VERSION_INDEX="3"
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
export SPARK_HOME="/content/spark-$CUSTOM_SPARK_VERSION-bin-hadoop$CUSTOM_HADOOP_VERSION"
export CUSTOM_SPARK_JARS="$SPARK_HOME/jars"