Skip to content

Instantly share code, notes, and snippets.

@chadcooper
chadcooper / latex-math.rst
Created May 30, 2013 22:29
Inserting LaTeX math inline and in block form into Sphinx documentation.

For a lens projecting a rectilinear image, the angle, or field of view (\alpha) can be calculated from the chosen dimension (d, the width of a 35mm image), and effective focal length (f, 35mm in Vue) as follows:

\alpha_h = 2\arctan\frac{d}{2f} = 2\arctan\frac{36}{2 \times 35}\approx 54^\circ
@chadcooper
chadcooper / diff-files.ps1
Created May 25, 2013 16:38
Diff'ing 2 files in PowerShell, in this case, XML files.
PS C:\<dir-where-files-are>> Compare-Object (Get-Content .\file-1.xml) (Get-Content '.\file-2.xml')
@chadcooper
chadcooper / merge-pdfs-osx.txt
Created May 25, 2013 16:35
Merge pdfs at the Terminal in OSX using GhostScript.
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf pdf-1.pdf pdf-2.pdf
import wx
class MyPanel(wx.Panel):
def __init__(self, parent, _id):
wx.Panel.__init__(self, parent, _id)
self.SetBackgroundColour("white")
default_font = wx.Font(9, wx.FONTFAMILY_DEFAULT,
wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.SetFont(default_font)
from xml.etree import ElementTree
class ConvertToFromXml(object):
class XmlDictObject(dict):
"""
Adds object like functionality to the standard dictionary.
"""
def __init__(self, initdict=None):
import wx
class MyPanel(wx.Panel):
def __init__(self, parent, _id):
wx.Panel.__init__(self, parent, _id)
self.SetBackgroundColour("white")
default_font = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.SetFont(default_font)
# Content goes here
import arcpy
in_polys = "NcCountiesT.shp"
in_points = "NcNatRegPts.shp"
desc = arcpy.Describe(in_polys)
oid_fld = desc.OIDFieldName
# Make featurelayers for input into SelectByLocation
@chadcooper
chadcooper / wx-panel-template.pyw
Created April 26, 2013 14:24
A little template to use when dorking around with wxpython and needing to test some functionality.
import wx
class MyPanel(wx.Panel):
def __init__(self, parent, _id):
wx.Panel.__init__(self, parent, _id)
self.SetBackgroundColour("white")
default_font = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.SetFont(default_font)
# Content goes here
@chadcooper
chadcooper / quadrant-textboxes.py
Last active December 16, 2015 15:59
Experimenting with building a cartesian-quadrant-like array of textboxes with a crosshair of lines separating them.
import wx
class MyPanel(wx.Panel):
def __init__(self, parent, _id):
wx.Panel.__init__(self, parent, _id)
self.SetBackgroundColour("white")
default_font = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
@chadcooper
chadcooper / vue-cartesian-cylinders.py
Created April 2, 2013 01:35
Places a cartesian array of cylinders on a planetary sphere in Vue. End result here: http://i.imgur.com/cwi6M5O.jpg
# Create the Cartesian array with Python:
>>> import itertools
>>> d = {}
>>> count = 1
>>> for i in itertools.product([0,100,200,300,400,500,600,700,800,900,1000],[0,-
100,-200,-300,-400,-500,-600,-700,-800,-900,-1000]):
... d[count] = list(i)
... count += 1
...