Skip to content

Instantly share code, notes, and snippets.

View bhousel's full-sized avatar

Bryan Housel bhousel

View GitHub Profile
@bhousel
bhousel / load_custom_iD_preset.js
Last active August 29, 2015 14:15
Load custom preset into #iD on the fly
obj = {
presets: {
'aerialway/zip_line': {
geometry: ["line"],
fields: ["incline"],
tags: { "aerialway": "zip_line" },
name: "Zipline"
}
}
};
@bhousel
bhousel / debug_entity_ids.js
Last active August 29, 2015 14:15
#iD debug mode - show ids instead of names
iD.util.displayName = function(entity) { return entity.id; }
@bhousel
bhousel / string_search_microsoft.sql
Created February 25, 2015 15:32
string search in Microsoft #SQL
DECLARE @search VARCHAR(255)
SET @search = '[10.10.100.50]'
SELECT DISTINCT
o.name AS Object_Name,
o.type_desc
FROM
sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id = o.object_id
WHERE
@bhousel
bhousel / history transplant.md
Last active August 29, 2015 14:16
Browser History Transplant for #iD

##iD history transplant

###Browser 1

  • Open "Help" and start walkthrough
  • Open developer console
  • Change "main frame/top frame" to "id-embed" if necessary, eg. running from openstreetmap.org
  • Run this:

(function getHistory() {

@bhousel
bhousel / whereami.js
Created March 15, 2015 19:29
Where am I (Nominatim lookup) #iD
// https://github.com/twain47/Nominatim/blob/master/lib/ReverseGeocode.php
function whereami(z) {
var endpoint = 'https://nominatim.openstreetmap.org/reverse?',
loc = id.map().center();
d3.json(endpoint +
iD.util.qsString({format: 'json', addressdetails: 1, lat: loc[1], lon: loc[0], zoom: z }),
function(err, result) { console.info(result); }
);
}
@bhousel
bhousel / latlng.js
Created April 19, 2015 02:54
Show lat/lng of mouse cursor in #iD
id.surface().on('mousemove.custom', function() {
function wrap(x, min, max) { var d = max - min; return ((x - min) % d + d) % d + min; }
var ll = d3.select('#content')
.selectAll('#latLng')
.data([0]);
ll.enter()
.append('div')
.attr('id', 'latLng')
@bhousel
bhousel / change_tags.js
Last active August 29, 2015 14:21
Hotkey to change some tags on all selected entities in #iD
context = id;
addTags = { building: 'yes' };
removeTags = ['area','natural','landuse'];
function changeTags() {
var actions = [],
entities = _.filter(_.map(context.selectedIDs(), context.entity),
function(entity) { return entity.geometry(context.graph()) === 'area'; });
_.each(entities, function(entity) {
@bhousel
bhousel / debug_events.js
Last active March 17, 2016 04:25
Debug Events
['touchstart', 'touchend', 'touchcancel',
'mousedown', 'mouseup',
'click', 'dblclick', 'contextmenu',
'dragstart', 'dragend',
'movestart', 'moveend',
'zoomstart', 'zoomend',
'rotatestart', 'rotateend',
'pitchstart', 'pitchend',
'boxzoomstart', 'boxzoomend', 'boxzoomcancel'
].forEach(function (type) {
@bhousel
bhousel / index.html
Last active November 30, 2015 22:30 — forked from tmcw/index.html
SVG Performance with paths and unrounded coordinates
<!DOCTYPE html>
<meta charset="utf-8">
<title>SVG Swarm</title>
<style>
svg {
position: absolute;
top: 0;
}
@bhousel
bhousel / index.html
Last active November 30, 2015 22:29 — forked from tmcw/index.html
SVG Performance with paths and rounded but long coordinates
<!DOCTYPE html>
<meta charset="utf-8">
<title>SVG Swarm</title>
<style>
svg {
position: absolute;
top: 0;
}