Skip to content

Instantly share code, notes, and snippets.

@WouterNieuwerth
WouterNieuwerth / ssgtm_variable_template.js
Created February 27, 2022 12:38
An example of a server-side GTM variable template that doesn't work ufortunately.
// A variable template that doesn't work, because it uses an asynchronous API.
const JSON = require('JSON');
const sendHttpRequest = require('sendHttpRequest');
sendHttpRequest('https://api.openweathermap.org/data/2.5/weather?lat=52.3746027&lon=6.6810724&appid=[enter_api_key_here]&units=metric&lang=nl', (statusCode, headers, response) => {
response = JSON.parse(response);
return response;
let Gpio
const express = require('express')
const router = express.Router()
// Onoff cannot be installed on devices without Gpio
try {
Gpio = require('onoff').Gpio
} catch (err) {
Gpio = {
accessible: false
from fuzzywuzzy import fuzz
from fuzzywuzzy import process
def fuzzy_flask(request):
"""Responds to a HTTP request.
Args:
request (flask.Request): HTTP request object.
Returns:
The response text or any set of values that can be turned into a
Response object using
// Add your own Cloud Function URL here:
var CLOUDFUNCTIONSURL = 'https://europe-west1-cloud-functions-example.cloudfunctions.net/example';
var search_terms = ["buy nike shoes", "adidas online", "rebok cloths"]; // With some spelling errors
var brands = ["nike", "adidas", "reebok"];
function main() {
var json = {
"searchterms": search_terms,
def hello_world(request):
"""Responds to any HTTP request.
Args:
request (flask.Request): HTTP request object.
Returns:
The response text or any set of values that can be turned into a
Response object using
`make_response <http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>`.
"""
request_json = request.get_json()
/**
* Responds to a HTTP request.
*
* @param {!express:Request} req HTTP request context.
* @param {!express:Response} res HTTP response context.
*/
exports.helloWorld = (req, res) => {
let example_content = req.body.example_content || 'Error, no example_content found in json';
let another_example_content = req.body.another_example_content || 'Error, no another_example_content found in json';
@WouterNieuwerth
WouterNieuwerth / make_post_request_from_ads_script_to_cloud_functions.js
Last active March 14, 2020 15:06
How to make a POST request from a Google Ads Script to a Google Cloud Function
// Add your own Cloud Function URL here:
var CLOUDFUNCTIONSURL = 'https://europe-west1-example.cloudfunctions.net/example';
function main() {
var json = {
"example_content": "Whatever you want to send to your Cloud Function",
"another_example_content": ["You", "can", "also", "use", "arrays", "here"]
};
var search_terms = ['buy nike shoes','adidas online','rebok cloths']; // With some spelling errors
var brands = ['nike','adidas','reebok'];
for (var i=0; i<search_terms.length; i++) {
for (var j=0; j<brands.length; j++) {
if(search_terms[i].indexOf(brands[j]) !== -1) {
// Do whatever you want to do when the search term contains a brand name
}
@WouterNieuwerth
WouterNieuwerth / GPX_analysis_step_complete.py
Last active June 28, 2023 20:55
GPX analysis - complete script
import gpxpy
import matplotlib.pyplot as plt
import datetime
from geopy import distance
from math import sqrt, floor
import numpy as np
import pandas as pd
import haversine
@WouterNieuwerth
WouterNieuwerth / GPX_analysis_step_8.py
Created February 9, 2020 18:36
GPX analysis - step 8
# Here we loop over sections
for section in sections:
if df['distance_dis_3d'].sum() < section: # If the total distance of the workout is smaller then the section we're looking for we can skip this iteration.
continue
df_output = pd.DataFrame(columns=['date', 'section', 'filename', 'time', 'distance', 'minutes_per_kilometer', 'total_distance', 'total_time'])
for i in range(len(df_selected.index)):