Skip to content

Instantly share code, notes, and snippets.

View TimMcCauley's full-sized avatar
🌏
Browsing around.

Timothy Ellersiek TimMcCauley

🌏
Browsing around.
  • Bonn, Germany
View GitHub Profile
@nilsnolde
nilsnolde / valhalla_traffic_tile_encoder.py
Last active May 20, 2022 09:12
How to encode traffic stuff for valhalla
from ctypes import *
import struct
from enum import Enum
"""
Converts valhalla's tile header & edge speeds into byte objects to be compressed.
"""
HEADER_FORMAT = '<2Q4L' # 2 uint_64, 4 uint_32 from the traffic header
@bpj
bpj / attr-color.lua
Last active February 12, 2024 08:11
A Pandoc filter which sets LaTeX text/background/frame color(s) on Span and Div elements based on Pandoc attributes.
--[==============================[
# attr-color.lua
A Pandoc filter which sets LaTeX text/background/frame color(s) on
Span and Div elements based on Pandoc attributes.
## Usage
See https://git.io/JI4yA
@geozelot
geozelot / ST_AsFeatureCollection.sql
Last active June 6, 2023 09:15
PostgreSQL/PostGIS - aggregate GeoJSON features into FeatureCollection
DROP AGGREGATE IF EXISTS public.ST_AsFeatureCollection(ANYELEMENT);
DROP AGGREGATE IF EXISTS public.ST_AsFeatureCollection(ANYELEMENT, TEXT);
DROP AGGREGATE IF EXISTS public.ST_AsFeatureCollection(ANYELEMENT, INT);
DROP AGGREGATE IF EXISTS public.ST_AsFeatureCollection(ANYELEMENT, TEXT, INT);
DROP AGGREGATE IF EXISTS public.ST_AsFeatureCollection(ANYELEMENT, INT, TEXT);
DROP FUNCTION IF EXISTS public._st_asfeaturecollection_transfn(collection TEXT[], item ANYELEMENT);
DROP FUNCTION IF EXISTS public._st_asfeaturecollection_transfn(collection TEXT[], item ANYELEMENT, TEXT);
DROP FUNCTION IF EXISTS public._st_asfeaturecollection_transfn(collection TEXT[], item ANYELEMENT, INT);
DROP FUNCTION IF EXISTS public._st_asfeaturecollection_transfn(collection TEXT[], item ANYELEMENT, TEXT, INT);
DROP FUNCTION IF EXISTS public._st_asfeaturecollection_transfn(collection TEXT[], item ANYELEMENT, INT, TEXT);
@davidheyman
davidheyman / prep_rasters.py
Created September 24, 2018 09:13
A script to clumsily deal with GeoTIFF transparency and data types and convert to MBTiles
"""Deal with raster transparency and convert to MBTiles"""
import os
import re
from string import Template
from shutil import copyfile
from osgeo import gdal
import rasterio
PATH = 'data/geotiff/'
import random
import json
from shapely.geometry import mapping, shape, Point
UK_SOME_POLY_BOUNDS='{"type": "Polygon","coordinates": [[[-0.280487,53.337084],[0.051368,52.540633],[0.228357,51.301708],[0.073491,51.146843],[-1.187557,51.168966],[-1.497288,51.080472],[-2.094627,51.080472],[-2.271616,51.345956],[-2.397953,51.653954],[-2.545269,52.095901],[-2.686179,52.76843],[-2.743825,53.120707],[-2.711799,53.351288],[-2.743825,53.665135],[-2.743825,53.69716],[-2.602914,54.23198],[-2.289067,54.302436],[-1.116946,54.385701],[-0.94401,54.340866],[-0.280487,53.337084]]]}'
#LONDON_BOUNDS='{"type":"Polygon","coordinates":[[[-0.071151117801821,51.51029343697843],[-0.07113642319992,51.5101295110986],[-0.071146828383437,51.50984908079782],[-0.071168171767067,51.50978737577289],[-0.071222527763646,51.50972891182979],[-0.07130137074254,51.50963667479025],[-0.071378125542731,51.50959386835587],[-0.071527914823977,51.50959633179286],[-0.071908376952806,51.509597191836676],[-0.072220312690561,51.50958253431118],[-0.0724368875
@vre2h
vre2h / simple-deploy.md
Last active March 4, 2024 15:06
Simple guide for deploying your react app to Github-Pages.
  1. Your package.json file should consist a field homepage:
  "homepage": "https://<github-username>.github.io/<project-repo>"

2.1. Install gh-pages via npm:

 npm i --save-dev gh-pages
@ankurk91
ankurk91 / xdebug-mac.md
Last active March 9, 2024 22:20
php xDebug v3 on Ubuntu/Mac and phpStorm

🪲 Install and Configure xDebug v3 on MacOS for PhpStorm 🐘

  • Assuming that you have already installed php and apache via Homebrew

  • Install xDebug php extension

pecl channel-update pecl.php.net
pecl clear-cache

pecl install xdebug
@habibutsu
habibutsu / distance.py
Last active October 29, 2021 15:38
Different ways calculate geo-distance in Python
'''
Requirements:
geographiclib==1.46.3
pyproj==1.9.5.1
geopy==1.11.0
git+https://github.com/xoolive/geodesy@c4eb611cc225908872715f7558ca6a686271327a
geo-py==0.4
'''
from math import radians, sin, cos, asin, sqrt, pi, atan, atan2, fabs
from time import time
#!/bin/bash
# Watoson plug-in for BitBar
# Watson: https://github.com/TailorDev/Watson
# BitBar: https://github.com/matryer/bitbar
# Save file as watson.5m.sh in plug-ins directory of BitBar and make it executable
source ~/.virtualenv/misc/bin/activate
WATSON_STATUS=`watson status`
python -c "
import sys
@m0neysha
m0neysha / pylist-to-markdown.py
Last active May 3, 2024 15:08
Python lists to markdown table
def make_markdown_table(array):
""" Input: Python list with rows of table as lists
First element as header.
Output: String to put into a .md file
Ex Input:
[["Name", "Age", "Height"],
["Jake", 20, 5'10],
["Mary", 21, 5'7]]