Sometimes it is convenient to try to develop with just npm rather than splitting into client and server versions using bower or whatever else.
npm init
npm install -D browserify
npm install -D browserify-shim
npm install -D watchify| #!python3 | |
| """ | |
| A script to read a document containing tables that I left as "verbatim" and | |
| format them properly in LaTeX. | |
| We go from this: | |
| \begin{verbatim} | |
| sparsity num_active accuracy test_accuracy train_accuracy | |
| count 4000.000000 4000.000000 4000.000000 4000.000000 4000 |
| PDFLATEX = pdflatex -interaction=batchmode -synctex=1 | |
| SH = /bin/bash | |
| ASCRIPT = /usr/bin/osascript | |
| SOURCE = master.tex | |
| BASE = "$(basename $(SOURCE))" | |
| default : pdf view | |
| .PHONY: pdf graphics |
| #!/bin/bash | |
| # Generate a PDF from a `.tex` file, then remove the auxiliary files with the same base name. | |
| # | |
| # Usage: | |
| # ./quicktex.sh myfile.tex | |
| # the first argument should be the tex file, either with or without extension | |
| file="$1" | |
| # remove the suffix (if it's .tex) |
| """ | |
| A simple implementation of vectors in Python modelled after tuples, but having | |
| altered some of the operations to be closer to vector arithmetic. | |
| It targets Python 3.5+ in order to support __matmul__, allowing for dot | |
| products, which I have heard are important in linear algebra. | |
| We check for whether it is operating on a number in order to implement | |
| broadcasting; otherwise it performs the operations elementwise. | |
| We also use `zip_longest` because it performs an implicit check for sequences | |
| of unequal length; it pads the iteration with `None`, which will raise an error |
| """ | |
| Code for extracting sliding windows from arrays. | |
| Particularly useful when you want to take patches from images prior to performing | |
| some operation on them, like convolution or computing the mean. | |
| """ | |
| import numpy as np | |
| from itertools import zip_longest | |
| from PIL import Image | |
| from numpy.lib.stride_tricks import as_strided |
| // Flatten a tree into an array by combining the keys. | |
| var flatten_tree = function(obj) { | |
| var sep = '/'; | |
| var ret = []; | |
| function _flat(elem, base) { | |
| base = ((base === undefined) ? '' : base + sep); | |
| for (let i in elem){ | |
| if (!elem.hasOwnProperty(i)) continue; | |
| let val = elem[i]; |
| #!/python3 | |
| """ | |
| Python threads with a `threading.Event` flag to allow for safe termination with | |
| a `KeyboardInterrupt`. | |
| While it is possible to have all threads abruptly terminate by setting | |
| `daemon == True` on the thread object, sometimes you need to perform cleanup, | |
| so we essentially set a flag for the threads to check, assuming they all work | |
| via an ongoing loop. | |
| Note that this flag could be any object that evaluates to `True` or `False`, |
| """ | |
| A quick logging setup and some helper functions. | |
| Some code taken from: http://inventwithpython.com/blog/2012/04/06/stop-using-print-for-debugging-a-5-minute-quickstart-guide-to-pythons-logging-module/ | |
| """ | |
| import logging | |
| # get a logger, set the logging level | |
| logger = logging.getLogger() | |
| logger.setLevel(logging.DEBUG) |
| """ | |
| A slightly more convenient alternative to the builtin `sorted()` which allows | |
| you to specify a key as something other than a function. | |
| For example, with a list of lists, if you wanted to sort by the last element you | |
| could use `sort(lstseq, key=-1)` rather than `sorted(lstseq, key=lambda x: x[-1])`. | |
| If your key *is* a function, it behaves identically to `sorted()`, because it is | |
| really just wrapping the builtin. | |
| Examples | |
| -------- |