This file contains hidden or 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
async function fetchVisitorGEO() { | |
const response = await fetch('https://empty-bird-5317.your-name.workers.dev/'); | |
const ipInfo = await response.json(); | |
console.log(ipInfo); | |
} | |
fetchVisitorGEO(); | |
/** OR */ |
This file contains hidden or 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
/** | |
Read more at: | |
https://abstractkitchen.com/blog/geolocation-with-cloudflare-workers/ | |
*/ | |
addEventListener("fetch", event => { | |
const city = event.request.cf.city; | |
const country = event.request.cf.country; | |
const clientIP = event.request.headers.get("CF-Connecting-IP"); |
This file contains hidden or 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 flask import Flask | |
app = Flask(__name__) | |
app.config["SERVER_NAME"] = "flaskapp.local:5000" | |
@app.route("/") | |
def root_index(): | |
return "this is flaskapp.local" |
This file contains hidden or 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
# | |
# this is part of https://abstractkitchen.com/blog/sitemaps-for-devs | |
# | |
import os | |
import gzip | |
from xml.etree import cElementTree | |
This file contains hidden or 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 coordtransform from "coordtransform"; | |
mapboxgl.accessToken = '<your mapbox access token>'; | |
let exampleMap; | |
// CHANGE WITH COORDINATES FROM HERE http://api.map.baidu.com/lbsapi/getpoint/ | |
const bd09Coords = [113.341334, 23.193119]; | |
function renderMap() { |
This file contains hidden or 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
function flatten(inputArray) { | |
/** | |
* One can argue that it's a good idea to validate inputArray | |
* value here, but i disagree. In this exact case it's better | |
* to not reinvent the wheel — if inputArray is not an Array | |
* application will throw error anyway at .reduce step | |
*/ | |
return inputArray.reduce((accumulator, current) => { |
This file contains hidden or 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
function getLocale() { | |
return (navigator.userLanguage || navigator.language || navigator.systemLanguage).toLowerCase(); | |
} |
This file contains hidden or 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
function loadScript(src, fn) { | |
var script, done, head; | |
script = document.createElement('script'); | |
script.src = src; | |
script.async = true; | |
script.onload = script.onreadystatechange = function() { | |
if (!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) { | |
done = true; |