Skip to content

Instantly share code, notes, and snippets.

View jaantollander's full-sized avatar

Jaan Tollander de Balsch jaantollander

View GitHub Profile
@jaantollander
jaantollander / geometry.py
Last active April 17, 2017 07:21
Converting shapely geometries to other objects
"""Convert shapely geometries to other objects
Other interfaces
- matplotlib: PathPatch
- pyqtgraph: PlotItem
- bokeh: Glyph
- scikit-image: Indices on a grid
References
@jaantollander
jaantollander / patterns.py
Last active May 21, 2017 07:03
Pycharm live templates for various Python patterns
# Pytest
def test_$NAME$():
assert True$END$
# Traitlets
@default('$NAME$')
def _default_$NAME$(self):
return $END$
@jaantollander
jaantollander / lprof.py
Created June 1, 2017 05:11
How to use Python line_profiler programatically
"""How to use line profiler [1]_ programatically. Code adapted from [2]_.
.. [1] https://github.com/rkern/line_profiler
.. [2] https://nvbn.github.io/2017/05/29/complexity/
"""
from line_profiler import LineProfiler
def main(*args, **kwargs):
"""Function to be profiled"""
@jaantollander
jaantollander / conf.py
Last active July 8, 2017 06:07
Sphinx configuration file example
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file is execfile()d with the current directory set to its
containing dir.
Note that not all possible configuration values are present in this
autogenerated file.
All configuration values have a default; values that are commented out
serve to show the default.
requirements:
@jaantollander
jaantollander / make_docs.py
Last active July 18, 2017 06:28
Livereload Sphinx
#!/usr/bin/env python
from livereload import Server, shell
package = "<package name>"
server = Server()
server.watch('docs/*.rst', shell('make html', cwd='docs'))
server.watch('docs/**/*.rst', shell('make html', cwd='docs'))
server.watch(f'{package}/**/*.py', shell('make html', cwd='docs'))
server.watch(f'{package}/*.py', shell('make html', cwd='docs'))
server.serve(root='docs/_build/html')
@jaantollander
jaantollander / unicode-math-symbols.csv
Last active October 12, 2022 09:40
List of unicode math symbols (separator uses ^)
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 1 column, instead of 2. in line 6.
# Unicode characters and corresponding LaTeX math mode commands
# *************************************************************
#
# :Copyright: © 2011 Günter Milde
# :Date: Last revised 2011-11-08
# :Licence: This work may be distributed and/or modified under the
# conditions of the `LaTeX Project Public License`_,
# either version 1.3 of this license or (at your option)
# any later version.
#
@jaantollander
jaantollander / notes.md
Created December 29, 2017 12:29
Web development course exam practice notes

HTML

Tags & Structure

Basic HTML Structure

<!DOCTYPE html>
<html>
  <head>
    <title>title</title>
    <meta> ... </meta>
    <link> ... </link>
@jaantollander
jaantollander / sympy_examples.ipynb
Last active October 4, 2023 11:16
SymPy examples.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jaantollander
jaantollander / value_based_dispatch.jl
Last active July 25, 2021 07:10
Value-based dispatch in Julia language
module ValueBasedDispatch
export MyType, A, B, C, f
abstract type MyType end
struct A <: MyType end
struct B <: MyType end
struct C <: MyType end
f(::Type{A}) = "Dispatch on argument A"
@jaantollander
jaantollander / install_julia.sh
Created July 23, 2021 08:15
Example of how to download and install Julia Language to home directory from the command line.
# You can choose a Julia release from https://julialang.org/downloads/
# Set URL for downloading Julia binaries
JULIA_URL="https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.2-linux-x86_64.tar.gz"
# Set name for the downloaded archive
JULIA_ARCHIVE="~/julia.tar.gz"
# Download the Julia language binaries
curl -o ${JULIA_ARCHIVE} ${JULIA_URL}