Skip to content

Instantly share code, notes, and snippets.

Avatar

Pirmin Kalberer pka

View GitHub Profile
@pka
pka / point.rs
Last active Oct 26, 2021 — forked from highway900/point.rs
writing a geometry to fgb format
View point.rs
fn write_file() {
let mut file = File::create("test_point.fgb").expect("failed to write point");
let points = [[1.0, 1.0], [2.0, 2.0]];
const MAGIC_BYTES: [u8; 8] = [b'f', b'g', b'b', 3, b'f', b'g', b'b', 0];
let _ = file.write(&MAGIC_BYTES);
let mut fbb = flatbuffers::FlatBufferBuilder::new();
let column_args = ColumnArgs {
name: Some(fbb.create_string("STATE_FIPS")),
@pka
pka / decode_flask_cookie.rs
Created Nov 30, 2019
Decode a Flask cookie with Rust
View decode_flask_cookie.rs
View filter_actors.rs
extern crate actix;
extern crate futures;
use actix::dev::{MessageResponse, ResponseChannel};
use actix::*;
use futures::{future, Future};
use std::env;
// Message and Response data type
#[derive(Debug)]
@pka
pka / quickfinder.sql
Last active Jun 9, 2017
Quickfinder adress search example
View quickfinder.sql
CREATE MATERIALIZED VIEW av.adressen AS
SELECT hau.pk, lok.r1_text || COALESCE(' ' || hau.r1_hausnum, '') AS adresse, hau.wkb_geometry
FROM av.ge_hausnummerpos hau
JOIN av.ge_lokalisationsnamepos lok ON lok.r1_benannt=hau.r1_gebaeud;
CREATE INDEX adressen_trgm_idx ON av.adressen USING gin (adresse gin_trgm_ops);
SELECT adresse,ST_AsBinary(wkb_geometry)::geometry
FROM av.adressen
WHERE similarity(adresse, %(search)s) > 0.2
@pka
pka / index.html
Last active Dec 17, 2015
Progressive WMS
View index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="http://dev.openlayers.org/releases/OpenLayers-2.12/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="http://dev.openlayers.org/releases/OpenLayers-2.12/examples/style.css" type="text/css">
<script src="http://dev.openlayers.org/releases/OpenLayers-2.12/OpenLayers.light.js"></script>
<script type="text/javascript">
View x.js
// generated by create search command
CmdUtils.makeSearchCommand({
name: "rails",
url: "http://apidock.com/rails/search?query={QUERY}",
icon: "http://apidock.com/images/favicon.ico",
parser: {
container: "#main_body > .result",
title: ".result_title > h3 > a",
maxResults: 10,
},