Skip to content

Instantly share code, notes, and snippets.

View lpinner's full-sized avatar

Luke Pinner lpinner

View GitHub Profile
@lpinner
lpinner / grive-sync
Created August 30, 2013 01:02
Grive sync on file/folder changes using inotifywait. See https://github.com/Grive/grive and http://www.webupd8.org/2012/05/grive-open-source-google-drive-client.html for info about grive. In Ubuntu you can add the grive-sync script to your startup applications to have it automatically monitor your local Google Drive folder.
I now use google-drive-ocamlfuse (https://github.com/astrada/google-drive-ocamlfuse).
For installation instructions see - http://www.webupd8.org/2013/09/mount-google-drive-in-linux-with-google.html
If you want my grive-sync inotifywait script, see the previous revision of this gist.
@lpinner
lpinner / wms-1.1.1-to-kml.xsl
Last active August 29, 2015 14:01
wms-to-kml
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is heavily modified by Luke Pinner (2014)
Originally from the ESIP-EDAC WMS to KML converter.
Which is copyright (c) 2009 Earth Data Analysis Center
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@lpinner
lpinner / rioarray.py
Last active May 18, 2018 09:19
rasterio and dask for multithreaded chunked raster operations
import numpy as np
import rasterio as rio
import dask
import dask.array as da
class RioDataset():
def __init__(self, filepath, band=1):
self.band = band
self.dataset = rio.open(filepath)
self.dtype = self.dataset.dtypes[band-1]
@lpinner
lpinner / setup.py
Last active April 7, 2016 02:28
Simple usercustomize.py to set up separate site.USER_BASE directories for 32 and 64bit python installs on Windows
from setuptools import setup
long_description = '''Simple usercustomize.py to keep separate site.USER_BASE/USER_SITE directories for 32 and 64bit
python installs on Windows.
Only required if you're installing extension modules (compiled pyd/dll) to the user site-packages directory, i.e.:
python setup.py install --user
pip install --user somepackage
@lpinner
lpinner / rerenamer.py
Last active August 23, 2019 21:51
Batch file renamer with regex and glob style searching
#!/usr/bin/python3
import os, sys
from urllib.parse import unquote, urlsplit
import fnmatch, re, sre_constants
from PyQt5 import uic
from PyQt5.QtCore import QObject, Qt
from PyQt5.QtWidgets import (
QWidget, QApplication, QDesktopWidget,
@lpinner
lpinner / tab_to_chordpro
Last active April 23, 2021 08:35
Convert tab to chordpro format
#!/usr/bin/env python3
# -*- coding: iso-8859-1 -*-
######################################################################
# Copyright: lpinner 2021
# License: Apache 2.0
#####################################################################
import os
import subprocess
@lpinner
lpinner / sampling.py
Last active November 8, 2018 04:54
Sampling
from enum import Enum
import numpy as np
class Transform(Enum):
linear = 'linear'
log = 'log'
equal = 'equal'
halfcauchy = 'halfcauchy'
@lpinner
lpinner / overlapping_windows.py
Last active May 28, 2021 12:17
rasterio overlapping windows
# Copyright 2019 Luke Pinner
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@lpinner
lpinner / resample_raster.py
Last active November 23, 2023 21:11
rasterio resample raster
# Copyright 2019 Luke Pinner
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@lpinner
lpinner / flatpak-themes
Last active October 22, 2020 22:28
Copy user or system GTK themes to flatpak runtimes
#!/usr/bin/python3
#licensed under the Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
""" Copy GTK themes to flatpak runtimes """
import sys
import shutil
import subprocess
from pathlib import Path
encoding = sys.getfilesystemencoding()