Code Snippets
Like any researcher/coder I have a few snippets and scripts that I use over and over. I'm storing some of them here for my own safekeeping, but they are publicly available for anyone who might find them useful. I don't need attribution for anything on this page, and you use them at your own risk.
LaTeX
- Macros: Imports my common packages and changes some settings for a look that is better than the default (in my opinion) and provides more functionality.
- GraphBuilder: Tikz/pgfplot is very useful, but it can slow down build times considerably, and some people retain older versions which give them graphs which don't look the same. This file allows all graphs to be built at one time with the same format and exported to PDFs with usable names which can be imported into the main document. Simply create .tikz files, then add a \includetikz{filename} in the document body as shown. Then run:
> pdflatex graphbuilder
> make -B -f graphbuilder.makefile
(yes, make exists for Windows, too).
I've provided two classes to format lines. You can use them, e.g. with \addplot+[SimpleLineOpts]. Then you can keep consistent line formats across all graphs.
Linux
- Deployment Script: When working on distributed systems it's common (at least for me) to have code or data files sitting on one machine that need to be copied to every node in the cluster. Simply list the nodes, one per line, in a file called workers.txt, then run this script. Right now it's set up to run on a machine that was accessed using ssh -A, so check the permissions on the ssh command. You will also need to change the file/folder names.
- Start Workers: This iteration of the script starts 4 SEEPng workers on each machine listed in workers.txt, and gives each one a CPU core affinity. Again, ssh -A was already used, so check your ssh permissions. Output is directed into a log named after the machine.
- Kill Workers: Sometimes elegant shutdown procedures are not available. This script simply kills all java processes running on the machines listed in workers.txt. So be careful there aren't other java processes you want to survive. As with the other scripts, ssh permissions are left as an exercise for the user.
- Collect Logs: Pulls the logs off the machines listed in workers.txt. and masters.txt into a subfolder /logs/ on the local machine (make sure to create this before running the script). If you want the logs to remain intact on the original machines just comment out the line with rm in it. ssh permissions left as an exercise for the user.
Javascript
- Interactive Graphing: This is a rough program that allows quick interactive graphs to be put online. It takes slightly modified CSV input into JSON (see mdfwombats.js - make sure to look at the very bottom where the arrays are added to the graphs). Then you can select which graphs you want displayed. You do have to select the graph (radio button) after the datasets (check boxes), but you can select and add multiple graphs. Refresh the page to clear them. Hover over a line to highlight it in all graphs, and click a line to toggle highlighting even when you aren't hovering.