$ uname -r
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
import typing | |
import pydantic | |
class File(pydantic.BaseModel, abc.ABC): | |
@classmethod | |
def __get_validators__(cls): | |
# one or more validators may be yielded which will be called in the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" xmlns=""> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Zoom Weirdness</title> | |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" /> | |
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"></script> | |
<style> | |
#map { | |
height: 500px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyproj | |
from shapely import wkt, geometry, ops | |
from functools import partial | |
def get_utm_zone(point: geometry.Point) -> int: | |
""" | |
Helper function to get the UTM Zone EPSG of the input point. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# ./list-dir-size.sh my_directory | |
# | |
du -hsx $1 | sort -rh | head -10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author: Tom Caruso | |
Divide up a box into multiple equal-size cells. | |
Helpful to split up a coverage of geometries into a gridded | |
Usage: | |
SELECT create_grid(array_agg(geom), 10, 10, 4326) FROM my_geometry_table; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Help for /r/learnpython: https://www.reddit.com/r/learnpython/comments/7kilzt/cant_get_my_head_around_using_argparse_in_my/ | |
""" | |
import argparse | |
import json | |
import pika | |
import sys | |
CONFIG_FILE = 'some_filename.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
container_stop_rm () { | |
docker rm $(docker stop $1) | |
} | |
_container_stop_rm () { | |
containers=$(docker ps --format '{{ .Names }}') | |
COMPREPLY=( $(compgen -W "$containers" -- "${COMP_WORDS[COMP_CWORD]}" ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read LOWERPORT UPPERPORT < /proc/sys/net/ipv4/ip_local_port_range | |
while : | |
do | |
PORT="`shuf -i $LOWERPORT-$UPPERPORT -n 1`" | |
ss -lpn | grep -q ":$PORT " || break | |
done | |
echo $PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DictAttr: | |
def __init__(self): | |
self.attr1 = "Let's go" | |
self.attr2 = "Pens!" | |
def __getitem__(self, item): | |
if getattr(self, item, None): | |
return getattr(self, item) | |
else: |