Skip to content

Instantly share code, notes, and snippets.

View arkottke's full-sized avatar
👨‍💻

Albert Kottke arkottke

👨‍💻
View GitHub Profile
@arkottke
arkottke / notes.md
Last active January 26, 2023 20:01
Vim windows and dynamic python
  1. Download vim x64 from: https://github.com/vim/vim-win32-installer/releases
  2. Check versions of Python with :version inside of vim. For example, look for -DDYNAMIC_PYTHON3_DLL
  3. Download Python 3.## Windows embeddable package (64-bit) from: https://www.python.org/downloads/windows/
  4. (optional) Use conda/mamba to install Python 2.7 as there isn't a embeddable package for Python 2.7
  5. Set paths in vimrc:
    set pythonhome=~/AppData/Local/mambaforge/envs/py2718/
    set pythondll=~/AppData/Local/mambaforge/envs/py2718/python27.dll

 set pythonthreehome=C:/opt/python-3.11.1-embed-amd64/
@arkottke
arkottke / requirements.txt
Last active July 22, 2022 13:49
gmprocess requirements
wheel
openquake-engine
obspy
pyasdf
vcrpy
pyzmq
configobj
fiona
opnepyxl
@arkottke
arkottke / README.md
Created May 3, 2022 22:17
Python logic tree

Logic tree

Simple interface for defining a logic tree with a JSON file, and then interating over the branches. Branches with zero weight are excluded. Branches can be limited by requires or excludes. Additional parameters can be passed with dictionaries to params.

@arkottke
arkottke / gist:479ec89d45aec6e966bb61986b3448c9
Created February 25, 2021 16:53
Updating git submodules
# First time only, init everything
git submodule update --init --recursive
# For git >1.8.2
git submodule update --recursive --remote
@arkottke
arkottke / conda_and_notebooks.txt
Created January 27, 2021 05:28
Proper use of conda and jupyter notebook
# Install jupyter in the base environment.
conda activate base
conda install -c conda-forge jupyterlab nb_conda_kernels jupyter_contrib_nbextensions
# Switch to an environment, and register it to jupyter
conda install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

Compiling HAZ45

The following set of instructions use 64-bit versions of the installers and packages (named x86_64), which should be appropriate for modern operating systems. If you have an older, 32-bit, you should use the i686 version. The sytem type can be found under the "System type:" field of System Information. On Windows 7, this can be accessed by: Start Menu -> Right Click "My Computer" -> Select Properties. On Windows 10, this can be accessed by opeining the Start Menu, then typing "About your PC.

  1. Download and install MSYS2 following the directions at the website. Note, that both x86_64 and i686 installers are available. MSYS2 provides a bash shell, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains.

  2. The installation process starts a MSYS bash shell, by default. Using this shell, we will update the packages to the latest version with: pacman -Syu. This update typically requires that the MSYS shell be

@arkottke
arkottke / thread_example.py
Created April 14, 2016 04:03
Example of using QThread and communicating progress
import time
from PySide import QtCore, QtGui
class Simulation(QtCore.QThread):
updateRange = QtCore.Signal(int, int)
updateProgress = QtCore.Signal(int)
def __init__(self, parent=None):
QtCore.QThread.__init__(self, parent)
@arkottke
arkottke / standard_chart.py
Created May 15, 2014 16:43
Standardize Excel charts to something a little more attractive.
#!/usr/bin/env python3
# encoding: utf-8
import re
import win32com.client
xl = win32com.client.gencache.EnsureDispatch('Excel.Application')
wb = xl.ActiveWorkbook
@arkottke
arkottke / gist:7659652
Created November 26, 2013 14:52
A little demo of np.recarrays
import numpy as np
r = np.rec.fromrecords([['foo', 1, 2.3], ['bar', 4, 5.6]], names=['s', 'i', 'f'])
r.s
>>> chararray(['foo', 'bar'], dtype='<U12')
r[1]
>>> ('bar', 4, 5.6)
@arkottke
arkottke / lookup.py
Last active December 16, 2015 23:39
Discussion of how to use shape files.
#!/usr/bin/env python
# encoding: utf-8
import csv
from osgeo import ogr, osr
class AbstractLookup:
def __call__(self, lon, lat):