Skip to content

Instantly share code, notes, and snippets.

CREATE OR REPLACE FUNCTION choose_other(x bigint, y bigint, z bigint) RETURNS bigint AS
$$
SELECT CASE x
WHEN y THEN z
ELSE y
END
$$ LANGUAGE SQL;
CREATE OR REPLACE FUNCTION node_connected_component(node_id bigint) RETURNS SETOF bigint AS
$$
CREATE OR REPLACE FUNCTION node_polygons(node_id bigint) RETURNS TABLE(visited bigint [], path bigint[], geometry Geometry(LINESTRING,4326)) AS
$$
WITH RECURSIVE n(id, visited, path, cycle, geometry) AS (
VALUES (node_id, ARRAY[node_id], ARRAY[]::bigint[], false, ST_GeomFromText('LINESTRING EMPTY'))
UNION ALL
SELECT
choose_other(n.id, l.src_node_id, l.dst_node_id),
n.visited || ARRAY[choose_other(n.id, l.src_node_id, l.dst_node_id)],
n.path || ARRAY[l.id],
choose_other(n.id, l.src_node_id, l.dst_node_id) = ANY (n.visited),
services:
demo:
tms:
kml:
use_grid_names: true
wmts:
wms:
md:
title: MML Maps
abstract:
@tlaitinen
tlaitinen / ui.ts
Last active November 6, 2017 13:20
Redux reducer example (TypeScript)
import {ActionCreator} from 'react-redux-typescript';
import {ModalType} from './modals';
import {RootState, Dispatch} from '@src/reducers';
import {omitBy} from 'lodash';
export interface State {
readonly loading: boolean;
readonly messages: Readonly<{[messageId:string]:string}>,
readonly modals: ReadonlyArray<ModalType>
}
type Map<A extends "A" | "B"> = {
"A": "A!",
"B": "B!"
}[A];
type AA = Map<"A">;
type BB = Map<"B">;
let a:AA = "A!";
import {ActionCreator} from 'react-redux-typescript';
export interface CrudResult {
results: string[];
totalCount: number;
}
export interface CrudState<E,Q> {
readonly queries: Readonly<{[queryName:string]: Q}>;
readonly results: Readonly<{[queryName:string]: CrudResult}>;
import tensorflow as tf
window_size = 10
batch_size = 10
data = tf.range(100)
indices = tf.data.Dataset.range(90)
window_fn = lambda x: data[x:x+window_size]
import {$call} from 'utility-types';
import {getType, createAction} from 'typesafe-actions';
import {ModalType} from './modals';
import {RootState} from '../reducers';
export interface State {
readonly loading: boolean;
readonly modals: ReadonlyArray<ModalType>;
}
import {actions, reducer} from './ui';
describe('ui actions', () => {
it('should create an action to set loading state', () => {
expect(actions.setLoading(true)).toEqual({
type: 'UI_SET_LOADING',
payload: true
});
});
it('should create an action to show modal', () => {
expect(actions.showModal({type:'dummy'})).toEqual({
import {createAction} from 'typesafe-actions';
import {SagaIterator} from 'redux-saga';
import {all, call, put, select} from 'redux-saga/effects';
export interface Results {
results: string[];
loading: boolean;
error?: string;
}
const defaultResults:Results = {