Skip to content

Instantly share code, notes, and snippets.

View mxttwoods's full-sized avatar
🎯
Focusing

Matthew Woods mxttwoods

🎯
Focusing
View GitHub Profile
@mxttwoods
mxttwoods / git-ignore-line.sh
Created January 26, 2023 14:41 — forked from aryelgois/git-ignore-line.sh
Git filter to ignore lines in your files
#!/bin/sh
# Git filter to ignore lines in your files.
#
# Copyright (c) 2017-2019 Aryel Mota Góis <aryel.gois@gmail.com>
#
# MIT License
#
#
# SETUP:
#
@mxttwoods
mxttwoods / buffer_in_meters.py
Created July 14, 2022 19:26 — forked from joaofig/buffer_in_meters.py
Python code to convert a geographic point into a circular buffer with radius in meters.
from shapely.geometry import Point
from functools import partial
from shapely.ops import transform
import pyproj
def buffer_in_meters(lng, lat, radius):
proj_meters = pyproj.Proj(init='epsg:3857')
proj_latlng = pyproj.Proj(init='epsg:4326')
project_to_meters = partial(pyproj.transform, proj_latlng, proj_meters)
@mxttwoods
mxttwoods / kml_io.py
Created March 28, 2022 14:13 — forked from mazzma12/kml_io.py
IO / Read and write KML file with geopandas and fiona driver
import fiona
import geopandas as gpd
# Enable fiona driver
gpd.io.file.fiona.drvsupport.supported_drivers['KML'] = 'rw'
# Read file
df = gpd.read_file(path, driver='KML')
# Write file
@mxttwoods
mxttwoods / custom-log-filtering-and-formatting.py
Created March 1, 2022 14:00 — forked from acdha/custom-log-filtering-and-formatting.py
Example of how to filter or apply custom formatting using Python's logging library
#!/usr/bin/env python
# encoding: utf-8
from pprint import pformat, pprint
import logging
class PasswordMaskingFilter(logging.Filter):
"""Demonstrate how to filter sensitive data:"""
@mxttwoods
mxttwoods / cli.java
Last active January 21, 2022 01:40
Apache Commons CLI Example
package io.segra;
/**
*
*/
public class Main {
public static void main(String[] args) {
// create the command line parser
@mxttwoods
mxttwoods / cli.kt
Created January 21, 2022 01:37
apache-commons-cli.kt
import org.apache.commons.cli.*
class App(args: Array<String>) {
var cliOptions: Options
var cliParser: DefaultParser
init {
cliOptions = Options()
setupOptions()
@mxttwoods
mxttwoods / .gitattributes
Created January 17, 2022 19:51 — forked from dreftymac/.gitattributes
Sample Git Attributes File
# Encrypt the repository
# Remove/modify this line if the repository is meant to be open-source
*.* filter=git-crypt diff=git-crypt
.gitattributes !filter !diff
# These files are text and should be normalized (Convert crlf => lf)
*.php text
*.css text
*.js text
*.htm text
@mxttwoods
mxttwoods / my_error.py
Created January 2, 2022 02:29
Custom Python Error
# A python program to create user-defined exception
# class MyError is derived from super class Exception
class MyError(Exception):
# Constructor or Initializer
def __init__(self, value):
self.value = value
# __str__ is to print() the value
@mxttwoods
mxttwoods / tmpctx.py
Created December 14, 2021 17:53
tmpfile factory
import contextlib
import os
import shutil
import tempfile
@contextlib.contextmanager
def cd(newdir, cleanup=lambda: True):
prevdir = os.getcwd()
os.chdir(os.path.expanduser(newdir))
try:
@mxttwoods
mxttwoods / hndlr.py
Created December 14, 2021 16:28 — forked from giumas/Logging - SQLite handler
A minimal SQLite handler for the python logging module
from __future__ import absolute_import, division, print_function, unicode_literals
import sqlite3
import logging
import time
__version__ = "0.1.0"
initial_sql = """CREATE TABLE IF NOT EXISTS log(