In response to a Stack Overflow question regarding centering a map given a GeoJSON object.
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 monthNames = [ | |
'January', 'February', 'March', 'April', 'May', 'June', 'July', | |
'August', 'September', 'October', 'November', 'December' | |
]; | |
function formatDate(date) { | |
return ( | |
monthNames[date.getUTCMonth()] + ' ' + | |
date.getUTCDate() + ', ' + | |
date.getUTCFullYear() |
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
<link rel="import" href="../ace-element/ace-element.html"> | |
<link rel="import" href="../topeka-elements/category-images.html"> | |
<link rel="import" href="../core-icon/core-icon.html"> | |
<link rel="import" href="../core-icons/core-icons.html"> | |
<link rel="import" href="../core-icons/av-icons.html"> | |
<link rel="import" href="../paper-fab/paper-fab.html"> | |
<link rel="import" href="../topeka-elements/category-icons.html"> | |
<polymer-element name="my-element"> |
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
/* | |
UPDATED for 2023 - Now much simpler. The old tricks are no longer needed. | |
The following code makes an 800×600 canvas that is always as sharp as possible for the device. | |
You still draw on it as if it's the logical size (800×600 in this case), but everything just | |
looks sharper on high-DPI screens. Regular non-sharp screens are not affected. | |
*/ | |
const width = 800 |
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
// convert three r,g,b integers (each 0-255) to a single decimal integer (something between 0 and ~16m) | |
function colourToNumber(r, g, b) { | |
return (r << 16) + (g << 8) + (b); | |
} | |
// convert it back again (to a string) | |
function numberToColour(number) { | |
const r = (number & 0xff0000) >> 16; | |
const g = (number & 0x00ff00) >> 8; |
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
"use strict"; | |
module.exports = function isSimpleClick(event) { | |
var isLeft = true; | |
var which = event.which; | |
if (!which && event.button != null) { | |
which = event.button & 1 ? 1 : event.button & 2 ? 3 : event.button & 4 ? 2 : 0; | |
} |
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
# make sure you have these installed: | |
npm install --global browserify uglify-js | |
# example command for 'chalk': | |
echo "var chalk = (function(){var _ref;" `echo "_ref = require('chalk');" | browserify --bare - | uglifyjs` "return _ref;}).call(this);" > bundled.js |
These projections are available in the geo.projection plugin.
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 modules = require('fs').readdirSync('node_modules').filter(function (name) {return name !== '.bin'}); | |
modules.forEach(function (m) { | |
console.time(m); | |
require(m); | |
console.timeEnd(m); | |
}); |
To set up:
- Clone this repo. (Or just copy
serve.go
into a folder on your computer). cd
into it, and rungo build serve.go
You can now run the binary like this: ./serve --root="/path/to/directory"
But to make it easier, put this in your .bashrc
: