This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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'; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)): |