Skip to content

Instantly share code, notes, and snippets.

@highway900
highway900 / write_fgb_file.rs
Last active November 17, 2021 22:46
Write fgb file with properties
pub fn write_fgb_file(filename: String, linestrings: &Vec<LineString<f64>>) -> Result<()> {
let mut fgb = FgbWriter::create(
"countries",
GeometryType::LineString,
Some(4326),
|header| {
header.description = Some(FgbWriter::create_string("Country polygons"));
},
)?;
fgb.add_column("fid", ColumnType::ULong, |col| {
@highway900
highway900 / point.rs
Last active October 26, 2021 11:31
writing a geometry to fgb format
fn point() {
let mut file = File::create("test_point.fgb").expect("failed to write point");
let hex = decode_hex("6667620366676201").unwrap();
file.write(&hex);
let mut fbb = flatbuffers::FlatBufferBuilder::new();
let column_args = ColumnArgs {
name: Some(fbb.create_string("STATE_FIPS")),
type_: ColumnType::String,
{ "type": "Feature", "properties": { "quadkey": "0320022310010123", "avg_d_kbps": 16493, "avg_u_kbps": 5746, "avg_lat_ms": 33, "tests": 1, "devices": 1, "avg_d_mbps": 16.493, "avg_u_mbps": 5.746 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -87.7752686, 33.1237508 ], [ -87.7752686, 33.1191502 ], [ -87.7697754, 33.1191502 ], [ -87.7697754, 33.1237508 ], [ -87.7752686, 33.1237508 ] ] ] } }
{ "type": "Feature", "properties": { "quadkey": "0320022310013121", "avg_d_kbps": 71670, "avg_u_kbps": 11379, "avg_lat_ms": 31, "tests": 1, "devices": 1, "avg_d_mbps": 71.67, "avg_u_mbps": 11.379 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -87.7313232, 33.0915415 ], [ -87.7313232, 33.0869393 ], [ -87.7258301, 33.0869393 ], [ -87.7258301, 33.0915415 ], [ -87.7313232, 33.0915415 ] ] ] } }
{ "type": "Feature", "properties": { "quadkey": "0320022310011011", "avg_d_kbps": 88182, "avg_u_kbps": 9731, "avg_lat_ms": 26, "tests": 1, "devices": 1, "avg_d_mbps": 88.182, "avg_u_mbps": 9.731 }, "geometry": { "type":
@highway900
highway900 / static-map.html
Created June 30, 2021 04:32
use map.on(<event> ...) to get the bounding box.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Highlight features within a bounding box</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.js"></script>
@highway900
highway900 / main.go
Created May 11, 2021 10:18 — forked from gjtorikian/main.go
Heroku chat sample
package main
import (
"encoding/json"
"io"
"log"
"net/http"
"os"
"github.com/go-redis/redis"
file one
@highway900
highway900 / gist:c866d2460ee1e92a6df05c97bb140044
Created September 1, 2020 23:52 — forked from hummus/gist:8592113
aws cli + jq example
wget http://stedolan.github.io/jq/download/linux64/jq
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \
"Name=instance-state-name,Values=running" \
| jq -r \
".Reservations[] | .Instances[] | .InstanceId" \
aws ec2 describe-volumes --filters \
"Name=status,Values=available" \
| jq -r ".Volumes[] | .VolumeId" \
@highway900
highway900 / multi_server.rs
Last active July 16, 2020 09:07
Shared state across multiple servers
use std::sync::{RwLock};
use futures::future;
use actix_web::{web, App, HttpServer};
struct AppStateWithCounter {
counter: RwLock<i32>,
}
@highway900
highway900 / hello.py
Created September 12, 2017 00:49
print hello world
def greet(name):
print('Hello', name)
if __name__ == '__main__':
greet('WWorld')
@highway900
highway900 / cross_compiler.md
Last active December 23, 2015 21:48
Cross compile environment for raspbian

Setup Cross compiler

Create an installation on an SDCARD or copy the contents of the raspian image to a new directory. Both will be referred to as 'raspbian' as a mount point

#Mount img

mkdir -p tmp raspbian
sudo mount rasp.img tmp -o loop -o offset=$((122880*512))
sudo cp -rpv tmp/. raspbian/.