Skip to content

Instantly share code, notes, and snippets.

@getflourish
getflourish / instructions.md
Last active March 3, 2017 11:22
Swiss Topo 2 Mapbox

Requirements

  • brew install gdal
  • brew install tippecanoe

1. Reproject

Shapefiles from Swiss sources might be available in EPSG:2056 (LV95) projection. To use these files in Mapbox, they need to be converted to EPSG:4326:

ogr2ogr -f "ESRI Shapefile" reprojected.shp original.shp -t_srs EPSG:4326 -s_srs EPSG:2056

@getflourish
getflourish / AppleWorks2MicrosoftWord.applescript
Last active December 30, 2016 11:05
Applescript to convert AppleWorks 6 documents to Microsoft Word files. This script will open each file of the source folder with AppleWorks and export each via the "Save as…" dialog to the output folder. The export format of the code example here is based on a German version of MacOS, but can be changed to any other format presented in the drop …
main()
on main()
set source_folder to choose folder with prompt "Choose a source folder."
set output_folder to choose folder with prompt "Choose an output folder."
set suffix to ".doc"
tell application "Finder"
set theFiles to (files of entire contents of source_folder) as alias list
importxxx
div[id^="substream"],
#pagelet_canvas_nav_content {
opacity:0;
pointer-events: none;
}
#pagelet_canvas_nav_content {
height: 1px !important;
}
@getflourish
getflourish / script.js
Created July 19, 2016 12:02
Sketch Dump
function dump (obj) {
log("#####################################################################################")
log("## Dumping object " + obj )
log("## obj class is: " + [obj className])
log("#####################################################################################")
log("obj.properties:")
log([obj class].mocha().properties())
log("obj.propertiesWithAncestors:")
log([obj class].mocha().propertiesWithAncestors())
log("obj.classMethods:")
@getflourish
getflourish / script.js
Last active July 18, 2016 09:07
Move images from a folder to subfolders named after each filename
var fs = require('fs'),
path = require('path');
var mkdirSync = function (path) {
try {
fs.mkdirSync(path);
} catch(e) {
if ( e.code != 'EEXIST' ) throw e;
}
}
@getflourish
getflourish / script.js
Created June 10, 2016 12:43
CSS class to show that an element is in prototype stage and not interactive
.is-prototype {
cursor: not-allowed;
pointer-events: none;
}
@getflourish
getflourish / script.js
Last active June 10, 2016 12:38
Keymaster setup
/**
** Keymaster understands the following modifiers: ⇧, shift, option, ⌥, alt, ctrl, control, command, and ⌘.
** The following special keys can be used for shortcuts: backspace, tab, clear, enter, return, esc, escape, space,
** up, down, left, right, home, end, pageup, pagedown, del, delete and f1 through f19.
**
*/
key('a', function(){ alert('you pressed a!') });
@getflourish
getflourish / script.js
Created June 10, 2016 12:36
Check if a color is light or dark
var getRGB = function(b){
var a;
if(b&&b.constructor==Array&&b.length==3)return b;
if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))return[parseInt(a[1]),parseInt(a[2]),parseInt(a[3])];
if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(b))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];
if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(b))return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],
16)];
if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(b))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];
return (typeof (colors) != "undefined")?colors[jQuery.trim(b).toLowerCase()]:null
};
@getflourish
getflourish / webfonts.html
Created June 5, 2016 09:51
Include Google Web Fonts
<link href='https://fonts.googleapis.com/css?family=Droid+Serif' rel='stylesheet' type='text/css'>