Skip to content

Instantly share code, notes, and snippets.

View WindfallLabs's full-sized avatar

Garin Wally WindfallLabs

View GitHub Profile
@WindfallLabs
WindfallLabs / test_load_dll.py
Created November 5, 2015 22:00
A short gist derrived from dlsw on how to test if a DLL is on your PATH
# A short gist derrived from dlsw on how to test if a DLL is on your PATH. (Best with try/except blocks)
import os
from ctypes import WinDLL
from _ctypes import FreeLibrary # DON'T FORGET THE '_'
dll = "mod_spatialite.dll" # or whatever DLL your heart desires
assert not dll in os.listdir(os.getcwd()) # Ensures that the DLL will not false-positive load because it's in the current working dir
loaded_dll = WinDLL(dll) # Attempt to load DLL. If the DLL is not on PATH or in os.getcwd() it will raise a WindowsError
FreeLibrary(loaded_dll._handle) # if successful, we should be good neigbors and unload it
del loaded_dll # completely rid of the memory instance
@WindfallLabs
WindfallLabs / read_spatialite_patch.py
Last active November 10, 2015 23:59
A proposed edition to geopandas.io for reading SpatiaLite data via wkt
"""Addition to geopandas.io.sql.py
by Garin Wally / Windfall Spatial, Nov 10, 2015
"""
# Place with the other imports
import shapely.wkt
def read_spatialite(sql, con, geom_col, crs=None, index_col=None,
coerce_float=True, params=None):
"""
@WindfallLabs
WindfallLabs / hellfire.py
Last active November 20, 2015 22:01
This script serves as a double-click DLL dependency-diagnostics utility.
# -*- coding: utf-8 -*-
"""
hellfire.py
This script serves as a double-click DLL dependency-diagnostics utility.
Usage:
1. Place this script in a folder containing one or many DLL(s) to test
2. Double-click this script
3. Read the Windows error-popup
@WindfallLabs
WindfallLabs / gdb_schema_yaml.py
Last active November 25, 2015 00:07
Creates a .yaml file 'psuedo-schema' from a folder directory (including ESRI gdb's)
# -*- coding: utf-8 -*-
"""distribution_yaml.py: Converts Paths and GBDs to dicts, then to a yaml file.
This script 'walks' through a folder structure (including ESRI Geodatabases)
and outputs a .yaml pseudo-schema of the directory-tree and geodatabase(s).
MIT License (MIT)
Copyright (C) 2015 Garin Wally / Windfall Spatial
This code was modified from code by Blake Miller, found here:
@WindfallLabs
WindfallLabs / dump_tests.py
Created May 26, 2016 21:34
Test apsw shell.py for `.dump > file.sql` functionality
# -*- coding: utf-8 -*-
import os
import codecs
from subprocess import Popen, PIPE
import apsw
db = "test.sqlite"
sqlite = "sqlite3_test.sql"
import locale
n = unicode(raw_input().decode(locale.getpreferredencoding()))
# Where the input is `José`
@WindfallLabs
WindfallLabs / get_users.py
Created July 7, 2016 15:21
get_users.py -- Searches Window's /Users/ file for write-accessable user folders
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
get_users.py -- Searches Window's /Users/ file for write-accessable user folders
and returns a list of write-accessible folder names (i.e. likely user name).
"""
import os
def get_users():
@WindfallLabs
WindfallLabs / switch.py
Last active November 27, 2016 15:35
A Python implementation of JavaScript switches
"""
swtich.py -- JS switches in Python (proof of concept)
Author: Garin Wally; Nov 2016
Just took the JavaScript tutorial at codecademy and thought switches were
pretty cool, so I coded one up in Python.
I have to admit, this implementation is not great, not pretty, and likely
not shorter than a standard if/elif/else block.
"""
@WindfallLabs
WindfallLabs / make_config.py
Created August 7, 2017 21:08
Makes a geojson-dashboard config.json file from an input geojson file.
# -*- coding: utf-8 -*-
"""
Makes a geojson-dashboard config.json file from an input geojson file.
Author: Garin Wally; Aug 2017
Use:
> python make_config.py us_bounds.json
"""
import os
@WindfallLabs
WindfallLabs / my_tweaks.zs
Last active November 12, 2019 05:58
ZenScript for MC Recipies
///// Variables
///// Removals
///// Replacements/Alterations
import minetweaker.item.IIngredient;
///////////////////////////////////////////////////////////////////////////////
// Variables
///////////////////////////////////////////////////////////////////////////////