Skip to content

Instantly share code, notes, and snippets.

View maximlt's full-sized avatar
🔎

Maxime Liquet maximlt

🔎
View GitHub Profile
@maximlt
maximlt / debug.md
Last active October 17, 2021 13:38
Debug a Panel or Lumen app with VS Code

Add this debug configuration that is going to serve the current file, i.e. the one with .servable() calls for Panel or a YAML file for Lumen:

  {
      "name": "Python: Panel",
      "type": "python",
      "request": "launch",
      "module": "panel",
 "args": [
@maximlt
maximlt / jlab.py
Last active September 29, 2021 09:15
Create a notebook including a title and some imports and run it in a conda environment with Jupyter Lab
#!/usr/bin/env python3
from datetime import date
import pathlib
import subprocess
import sys
def create_nb(nb_dir: str, extra_title: str = None) -> pathlib.Path:
today = date.today()
title = today.strftime("%B %d, %Y")
@maximlt
maximlt / RemoteDebuggingQgisVsCode.md
Last active December 21, 2020 17:02 — forked from veuncent/RemoteDebuggingQgisVsCode.md
Remote debug QGIS with VS Code
  1. Install ptvsd using the same Python interpreter Qgis uses. E.g. on Windows:
C:\OSGeo4W64\apps\Python37\python.exe -m pip install ptvsd==4.3.2 

And on Linux:

pip3 install --user ptvsd
@maximlt
maximlt / environment.yml
Created July 9, 2020 11:58
Test for deploying latest panel version on binder
name: panel_last_env
channels:
- pyviz
- conda-forge
dependencies:
- panel
- jupyterlab
@maximlt
maximlt / run_python_script_in_conda_env.bat
Last active September 14, 2024 12:08
Run a Python script in a conda environment from a batch file
@echo OFF
rem How to run a Python script in a given conda environment from a batch file.
rem It doesn't require:
rem - conda to be in the PATH
rem - cmd.exe to be initialized with conda init
rem Define here the path to your conda installation
set CONDAPATH=C:\ProgramData\Miniconda3
rem Define here the name of the environment
@maximlt
maximlt / hook-panel.py
Created April 23, 2020 17:47
Bundling a panel app as an exe with PyInstaller
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('panel', include_py_files=True) + \
collect_data_files('pyviz_comms', include_py_files=True) + \
collect_data_files('bokeh') # See https://github.com/pyinstaller/pyinstaller/pull/4746
@maximlt
maximlt / GitHub-Forking.md
Created April 18, 2020 18:09 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@maximlt
maximlt / environment.yml
Last active April 13, 2020 08:34
Test Binder Env for Holoviews
name: holoviews
channels:
- conda-forge
dependencies:
- pyviz::holoviews=1.13*
# Install requires
- pyviz::param>=1.8.0,<2.0
- pyviz::pyviz_comms>=0.7.2
@maximlt
maximlt / make_conda_available_on_windows.md
Last active February 23, 2024 18:07
Make conda easily available on Windows

Make conda easily available on Windows

The goal is to lower the burden of running a script with Python when that Python executable is encapsulated within a conda environment. There are several ways to do that.

Add Anaconda Prompt to Windows right click context menu

Adapted from jiewpeng's gist (original gist here)

This describes how to add Anaconda Prompt to the Windows right click context menu. In doing so, the user can open a Command Prompt in any folder from the File Explorer, which is going to be activated

@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