Skip to content

Instantly share code, notes, and snippets.

View demographus's full-sized avatar

demographus demographus

View GitHub Profile
@tlfrd
tlfrd / .block
Last active April 8, 2023 19:44
Destination Globe (Spinning + Versor Drag)
license: mit
@danyn
danyn / isNodeList.html
Last active February 24, 2021 20:36
Determine if a js object is a nodeList (HTML collection) like that returned by getElementsByClassName
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js - isNodeList</title>
<style>
#y{
color:red;
}
.y{
@andybarefoot
andybarefoot / .block
Last active January 14, 2023 15:45
Responsive interactive D3.js map
license: gpl-3.0
@mbostock
mbostock / .block
Last active April 8, 2023 19:39
Versor Dragging
license: gpl-3.0
height: 600
border: no
redirect: https://observablehq.com/@d3/d3-versor-dragging
@armollica
armollica / .block
Last active November 8, 2021 21:38
Proj4/WKT + D3
height: 600
@mhoffmann
mhoffmann / loadGeoIp.sh
Created June 28, 2016 02:46
script to load GeoLite2 Database into MySQL
#!/usr/bin/env bash
#apt-get install -y unzip
wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City-CSV.zip
unzip GeoLite2-City-CSV.zip
cd GeoLite2-City-CSV_*
mv GeoLite2-City-Blocks-IPv4.csv /tmp/GeoLite2-City-Blocks-IPv4.csv
mv GeoLite2-City-Locations-en.csv /tmp/GeoLite2-City-Locations-en.csv
mysqladmin create geoip
@ttfkam
ttfkam / pg_geolite2_csv.sql
Last active April 18, 2023 03:44
GeoLite2 for PostgreSQL
-- GeoLite2 CSV files for use with PostgreSQL 9+
-- by Miles Elam <miles@geekspeak.org>
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@douglyuckling
douglyuckling / README.md
Last active January 24, 2022 00:07
Dynamic Map Simplification with Simple Viewport-Based Culling

This Gist is meant to be viewed on bl.ocks.org. Check out the full project on GitHub.

This is a little example to experiment with high-performance interactive maps. Mike Bostock has several examples of using dynamic simplification with maps, but I needed to expand on them in a few ways:

  • I want to change the projections on the fly, so I wanted to avoid baking a projection into my data.
  • I need to project the entire world instead of just one country or region.
  • When zooming in on an area, I wanted to avoid projecting unnecessary data. (E.g. countries outside the viewport.)

This example does all of those things. Here's an overview:

@steveathon
steveathon / serverExplode.php
Created August 18, 2014 12:32
Explode PHP $_SERVER['REQUEST_URI'];
<?php
$URIParts = explode('?',$_SERVER['REQUEST_URI']);
$URI = explode('/',$URIParts[0]);
// Shift the array, to move it past the 'root'
@array_shift($URI);
// Now, get rid of any pesky empty end slashes
while ( @count($URI) > 0 && !end($URI) ) {
@array_pop($URI);
}
@Tomalak
Tomalak / isNodeList.js
Last active May 11, 2024 15:22
A function to test if a JavaScript object is a DOM NodeList. This is designed to work across all browser implementations. StackOverflow question reference http://stackoverflow.com/a/7238344/18771.
/* Released under the MIT License in 2014. http://opensource.org/licenses/mit-license */
function isNodeList(nodes) {
var stringRepr = Object.prototype.toString.call(nodes);
return typeof nodes === 'object' &&
/^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
nodes.hasOwnProperty('length') &&
(nodes.length === 0 || (typeof nodes[0] === "object" && nodes[0].nodeType > 0));
}