Skip to content

Instantly share code, notes, and snippets.

@raydouglass
raydouglass / ffmpeg_nvidia.sh
Last active February 21, 2024 00:06
Compile ffmpeg 6.0 with NVIDIA hardware acceleration
#!/usr/bin/env bash
set -euxo pipefail
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
if ! command nvcc --version >/dev/null 2>&1; then
@wriglz
wriglz / national_park_voronoi.sql
Last active January 17, 2023 12:56
SQL to generate Voronoi Polygons to determine National Park catchment areas.
/*
Data sources for National Park boundaries:
- England: https://environment.data.gov.uk/DefraDataDownload/?mapService=NE/NationalParksEngland&Mode=spatial
- Scotland: https://spatialdata.gov.scot/geonetwork/srv/eng/catalog.search#/home
- Wales: https://datamap.gov.wales/layers/inspire-nrw:NRW_NATIONAL_PARK
*/
WITH
park_info AS(
-- Select required information about each National Park from a merged dataset
@wriglz
wriglz / snap_points_to_lines.sql
Last active September 1, 2022 04:21
SQL to snap points to the closest line within a predefined radius
-- Snap the points to their closest lines, found in the subquery below
SELECT
point_id,
line_id,
ST_LINE_INTERPOLATE_POINT(line_geom,
ST_Line_Locate_Point(line_geom, point_geom)) AS snapped_points --Create the snapped points
FROM
--Subquery to find the closest line to each point (within a pre-defined raidus)
(
@leighajarett
leighajarett / gis_examples.ipynb
Last active March 22, 2024 16:56
Examples for leveraging the BigQuery Public Geo Boundaries tables for geospatial analytics
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
create table hex_r8 as (
with envelope as (
select st_envelope(wkb_geometry) geom from quartiers_sociologiques
), h3_id as (
select h3_polyfill(geom, 8) id from envelope
)
select id, st_setsrid(h3_h3index_to_geoboundary(id), 4326) geom from h3_id
);
@janbenetka
janbenetka / h3_in_bigquery.sql
Last active October 27, 2022 10:02
[H3 hexagon functions in BigQuery] #h3 #hex
SELECT jslibs.h3.ST_GEOGPOINTFROMH3("u2ce02j")
SELECT jslibs.h3.ST_H3_BOUNDARY(jslibs.h3.ST_H3(ST_GEOGPOINT(13.377534960188237, 49.747300576525554), 11))
SELECT jslibs.h3.h3GetResolution("u2ce02j");
# lat/lon to hexagon
SELECT jslibs.h3.ST_H3(ST_GEOGPOINT(statistics.coordinate.longitude, statistics.coordinate.latitude), 10) AS dwell_hex_id,
WITH polygon AS (
@270ajay
270ajay / advancedModeling2Week1.py
Created December 24, 2020 11:44
Advanced constraint programming modeling - 2
from ortools.sat.python import cp_model
''' course: https://www.coursera.org/learn/solving-algorithms-discrete-optimization#about
About how cp works and intro to solver strategies'''
def patchingThe9HeavensProblem(): #sudoku problem
model = cp_model.CpModel()
# IDA (disassembler) and Hex-Rays (decompiler) plugin for Apple AMX
#
# WIP research. (This was edited to add more info after someone posted it to
# Hacker News. Click "Revisions" to see full changes.)
#
# Copyright (c) 2020 dougallj
# Based on Python port of VMX intrinsics plugin:
# Copyright (c) 2019 w4kfu - Synacktiv
@Mizux
Mizux / vrp_new_order.py
Last active December 17, 2023 16:03
VRP with a new order
#!/usr/bin/env python3
"""Capacited Vehicles Routing Problem (CVRP).
Here we simulate a vehicle already loaded with 4 orders and on its way to deliver them
When a new order (node 5 -> 6) arrives.
"""
from ortools.constraint_solver import routing_enums_pb2
from ortools.constraint_solver import pywrapcp
def print_solution(manager, routing, solution):
@Alex3917
Alex3917 / gist:de07c7e181b61133662af5c76d3ea869
Created September 1, 2020 01:54
How to configure nginx for ElasticBeanstalk with Python on Amazon Linux 2
worker_processes 1;
user nginx;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # set to 'on' if nginx worker_processes > 1
}