Skip to content

Instantly share code, notes, and snippets.

View tvoirand's full-sized avatar

Thibaut Voirand tvoirand

View GitHub Profile
@maximlt
maximlt / project_config.md
Last active March 18, 2024 19:49
Creating a project base

Steps to create a good project base for developing in a conda environment

Step-by-step (uncomplete) tutorial for setting up a base Python library given the following requirements:

  • Use conda (instead of pipenv or others) because this is both a package manager and an environment manager, and installing the Python scientific stack (Numpy, Pandas, Scipy, Matplotlib, etc.) is straightforward
  • Use Visual Studio Code (instead of PyCharm, Spyder or others) because it's free, runs on Windows and is one of the mostly used IDE
  • Document and automate as many production steps as possible including linting (flake8), formatting (black), packaging (setup.py, setup.cfg), versionning (git), testing (pytest, pytest-cov, tox), documenting (sphinx, readthedocs), building (setuptools) and distributing (twine, keyring)
  • Include IPython Notebooks and have them tested (pytest-nbval)

Table of content

@krzysztof-slowinski
krzysztof-slowinski / sftp_sync.py
Last active January 25, 2023 05:43
Pysftp - get only the changed files from the remote directory
import os
import configparser as cp
import shutil
import pysftp
import paramiko
from paramiko.py3compat import decodebytes
# credentials file name
CREDENTIALS_FILE = 'sftp_sync_credentials.properties'
@artlogic
artlogic / ftprmtree.py
Created May 8, 2012 04:44
Python ftplib rmtree
def FtpRmTree(ftp, path):
"""Recursively delete a directory tree on a remote server."""
wd = ftp.pwd()
try:
names = ftp.nlst(path)
except ftplib.all_errors as e:
# some FTP servers complain when you try and list non-existent paths
_log.debug('FtpRmTree: Could not remove {0}: {1}'.format(path, e))
return
@sgillies
sgillies / geo_interface.rst
Last active July 9, 2024 15:21
A Python Protocol for Geospatial Data

Author: Sean Gillies Version: 1.0

Abstract

This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.

Introduction

@flags
flags / bresenhamalgorithm.py
Created August 8, 2011 18:26
Bresenham's line algorithm in Python
class bresenham:
def __init__(self, start, end):
self.start = list(start)
self.end = list(end)
self.path = []
self.steep = abs(self.end[1]-self.start[1]) > abs(self.end[0]-self.start[0])
if self.steep:
print 'Steep'