Skip to content

Instantly share code, notes, and snippets.

View michaelwooley's full-sized avatar

Michael Wooley michaelwooley

View GitHub Profile
@hugke729
hugke729 / Sublime and Python (Windows).md
Last active August 7, 2023 15:03
Use Sublime and Spyder together in a REPL-like fashion

Running a Python script or selected code from Sublime in Spyder's IPython console

A supplement to the Brushing Up Science post: Invest in a good text editor

I like to use both Python and Sublime Text. But I also like Spyder as a Python IDE. Therefore, although I edit in Sublime, to run scripts or evaluate lines of code in a REPL-like fashion, I do so via Spyder. Detailed below is how I achieve this in such a way that if I want to run the file or evaluate the selected lines, I simply press Shift + Enter.

This example works for Windows using AutoHotKey. For Linux instructions, click here.

Step 1: AutoHotKey code

@DrDub
DrDub / selectfile.py
Created January 3, 2016 11:44
A file selection class build for ipywidgets without any extra dependencies.
import os
import ipywidgets as widgets
class FileBrowser(object):
def __init__(self):
self.path = os.getcwd()
self._update_files()
@frankrowe
frankrowe / shp2gj.py
Last active November 1, 2022 17:54
PyShp, shp to geojson in python
import shapefile
# read the shapefile
reader = shapefile.Reader("my.shp")
fields = reader.fields[1:]
field_names = [field[0] for field in fields]
buffer = []
for sr in reader.shapeRecords():
atr = dict(zip(field_names, sr.record))
geom = sr.shape.__geo_interface__
buffer.append(dict(type="Feature", \