Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Gratier ThomasG77

View GitHub Profile
View react-bias.md

React Bias

It may seem like a bold suggestion that we as web developers can choose the wrong tools for the job because we tend to be swayed by appeals to popularity or authority, but simple statistics imply just that. For example, React (https://reactjs.org/) is a JavaScript framework that emphasizes componentization and simplified state management. It enjoys strong advocacy from a vocal and dedicated userbase within the developer community.

Despite React’s apparent popularity, however, The HTTP Archive observed in 2020 that React only accounted for 4% of all libraries in use across the 7.56 million origins it analyzed (https://almanac.httparchive.org/en/2020/javascript#libraries).

For context, The State of JS 2020 Survey (https://2020.stateofjs.com/en-US/), which surveyed roughly 23,765 respondents, offers the following statistics:

  • 70.8% of respondents identified as white.
  • 91.1% identified as male, whereas 5.8% identified as female and 0.9% identified as non-binary/third gender.
@adactio
adactio / saveTextarea.js
Last active Jan 7, 2021
Put the contents of a textarea into localStorage if the user leaves the page before submitting the form.
View saveTextarea.js
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function (win, doc) {
// Cut the mustard.
if (!win.localStorage) return;
// You should probably use a more specific selector than this.
var textarea = doc.querySelector('textarea');
// The key for the key/value pair in localStorage is the current URL.
var key = win.location.href;
@tomhicks
tomhicks / plink-plonk.js
Last active Feb 15, 2021
Listen to your web pages
View plink-plonk.js
@pramsey
pramsey / vsicurl_ogr_fdw.sql
Last active Nov 25, 2019
OGR FDW against remote static files
View vsicurl_ogr_fdw.sql
--
-- Not only does this FDW definition read a remote file over HTTP and provide
-- a tabular view of the data, it also does so even though the file
-- is encased in a ZIP file!
-- See https://gdal.org/user/virtual_file_systems.html for more magic.
--
CREATE EXTENSION postgis;
CREATE EXTENSION ogr_fdw;
CREATE SERVER myserver
@JamesChevalier
JamesChevalier / overpass_query_all_streets.md
Last active Mar 1, 2021
Overpass API query to retrieve all streets in a city
View overpass_query_all_streets.md

An area ID in Overpass is the OSM relation ID + 3600000000

This information is kind of buried in the Overpass API wiki page documenting the available filters: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#By_area_.28area.29

The OSM relation ID can be seen in two places:

  • Visit https://www.openstreetmap.org and search for the city
  • Click on its entry and you will be taken to a https://www.openstreetmap.org/relation/SOME_NUMBER_HERE page
  • The relation ID is in the URL as "SOME_NUMBER_HERE" in the bullet point above
  • The relation ID will also be in parentheses next to the city name in the left column
@mdouchin
mdouchin / qgis_deploy_install_upgrade_ltr.ps1
Created Jun 11, 2019 — forked from Guts/qgis_deploy_install_upgrade_ltr.ps1
Use OSGeo4W installer command-line abilities to provide a real-life example like downloading and installing QGIS LTR full meta-package
View qgis_deploy_install_upgrade_ltr.ps1
#Requires -RunAsAdministrator
<#
.Synopsis
Download the OSGeo4W installer then download and install QGIS LTR (through the 'full' meta-package).
.DESCRIPTION
This script will:
1. change the current directory to the user downloads folder
2. download the OSGeo4W installer
3. launch it passing command-line parameters to DOWNLOAD packages required to QGIS LTR FULL
@Guts
Guts / qgis_deploy_install_upgrade_ltr.ps1
Last active Feb 17, 2021
Use OSGeo4W installer command-line abilities to provide a real-life example like downloading and installing QGIS LTR full meta-package
View qgis_deploy_install_upgrade_ltr.ps1
#Requires -RunAsAdministrator
<#
.Synopsis
Download the OSGeo4W installer then download and install QGIS LTR (through the 'full' meta-package).
.DESCRIPTION
This script will:
1. change the current directory to the user downloads folder
2. download the OSGeo4W installer
3. launch it passing command-line parameters to DOWNLOAD packages required to QGIS LTR FULL
@veltman
veltman / tiles.md
Last active Sep 27, 2019
Making a big image zoomable
View tiles.md

Making a big image zoomable

When you have a giant image and you want to make it easy to pan and zoom without downloading the whole 50MB image into someone's browser, a nice workaround is to cut that image into tiles at different zoom levels and view it as it were a map. An example where I've used this technique is The "Snowpiercer" Scenario.

One way to cut your big image into the requisite tiles is with gdal2tiles.py.

Alternatively, this Node script will do the cutting after you install node-canvas and mkdirp:

const fs = require("fs"),
@aborruso
aborruso / gdal_ecw.sh
Created Mar 28, 2019 — forked from geodavey/gdal_ecw.sh
Install GDAL 2.3 with ECW support on Ubuntu 18.04
View gdal_ecw.sh
#!/bin/bash
##
## Tested on: Ubuntu 18.04 & ECW 5.4 & GDAL 2.3.1
##
## Download the ERDAS ECW JP2 SDK v5.4 Linux
## https://download.hexagongeospatial.com/downloads/ecw/erdas-ecw-jp2-sdk-v5-4-linux
## Download GDAL v2.3 Source (ex. 2.3.1)