Skip to content

Instantly share code, notes, and snippets.

@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
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 / 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"]
};
/**
* 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';
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()
// 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,
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
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
@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;
@WouterNieuwerth
WouterNieuwerth / ssgtm_tag_template_sendHttpRequest.js
Created February 27, 2022 13:00
This Server-side GTM tag template makes a request to openweathermap.org and parses the JSON response.
// An example tag template that makes a request to OpenWeatherMap.org
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);
// Do something with the response.