Skip to content

Instantly share code, notes, and snippets.

View allthesignals's full-sized avatar
🥑
coding lotsa code

Matt Gardner allthesignals

🥑
coding lotsa code
View GitHub Profile
WITH
filtered_selection AS (
SELECT *
FROM demographic
WHERE geoid IN ('1000201','1000202','1000600','1000800','1001001','1001002','1001200','1001401','1001402','1001600','1001800','1002000','1002201','1002202','1002400','1002500','1002601','1002602','1002700','1002800','1003001','1003002','1003200','1003400','1003601','1003602','1003800','1004000','1004400','1004800')
),
enriched_selection AS (
SELECT *
FROM filtered_selection
@allthesignals
allthesignals / controllers.application.js
Last active March 30, 2018 16:28
Ember data tasks notifyAfterLoad example
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import { Promise } from 'rsvp';
import Config from '../../config/environment';
import MapboxGl from 'mapbox-gl';
import QUnit from 'qunit';
MapboxGl.accessToken = Config['mapbox-gl'].accessToken;
export default function createMap() {
return new Promise((resolve) => {
@allthesignals
allthesignals / controllers.application.js
Last active April 30, 2018 02:14
Ember Query Params Dynamic
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@allthesignals
allthesignals / dynamic-query-params.js
Created April 30, 2018 19:29
Aliased & observed properties from a collection of models
import Service from '@ember/service';
import EmberObject from '@ember/object';
import { alias } from '@ember/object/computed';
export default class DynamicQueryParamsService extends Service {
setup(expected, received) {
// map and alias model prop references to public properties
const aliasedObjectMap = expected
.reduce((acc, layerGroup) => {
const id = layerGroup.get('id');
/**
@module Discourse
*/
var get = Ember.get, set = Ember.set;
var popstateFired = false;
var supportsHistoryState = window.history && 'state' in window.history;
// Thanks: https://gist.github.com/kares/956897
var re = /([^&=]+)=?([^&]*)/g;
import { module, test, skip } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
module('Integration | Component | layer-menu-item', function(hooks) {
setupRenderingTest(hooks);
test('it opens and closes on click', async function(assert) {
await render(hbs`{{layer-menu-item title='Foo'}}`);
export default class ProjectsMapComponent extends Component {
@restartableTask
projectCentroidsSource = function*() {
const sourceLayers = [{
id: 'project-centroids',
sql: 'SELECT * FROM project_centroids',
}];
const tileURL = yield carto.getVectorTileTemplate(sourceLayers);
@allthesignals
allthesignals / gist:fe1892bcaaa2d01015efe24d9cc21192
Last active June 23, 2018 17:51 — forked from chriswhong/gist:762ceac7fb8a1420e7e7adceb770b707
Using ST_AsMVT() and ST_AsMVTGeom() in express to build a vector tile endpoint
/* GET /tiles/:z/:x/:y.mvt */
/* Retreive a vector tile by tileid */
router.get('/tiles/:z/:x/:y.mvt', async (req, res) => {
const { z, x, y } = req.params;
// calculate the bounding polygon for this tile
const bbox = mercator.bbox(x, y, z, false);
// Query the database, using ST_AsMVTGeom() to clip the geometries
// Wrap the whole query with ST_AsMVT(), which will create a protocol buffer
{{#filter-section
filterTitle='Borough / Block'
appliedFilters=applied-filters
filterNames=(array 'boroughs' 'block')
mutateArray=(action 'mutateArray')
as |section|
}}
<ul class="menu vertical medium-horizontal stage-checkbox">
{{#each (array 'Citywide' 'Manhattan' 'Bronx' 'Brooklyn' 'Queens' 'Staten Island') as |type|}}
<li {{action section.delegate-mutation (action 'mutateArray' 'boroughs' type)}}>