Skip to content

Instantly share code, notes, and snippets.

View benkehoe's full-sized avatar

Ben Kehoe benkehoe

View GitHub Profile
@benkehoe
benkehoe / getch.py
Last active May 22, 2018 07:57
Python stdin char getter
"""
Copyright 2018 Ben Kehoe
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTH
@benkehoe
benkehoe / JSON <-->YAML coversion scripts.md
Last active August 26, 2020 15:25
JSON <--> YAML conversion scripts

JSON <--> YAML conversion scripts

JSON is very standard. YAML, a superset of JSON, is very readable. Got something that needs JSON, and want to write the input in YAML? Use yaml2json. Have JSON and want to view it in a more readable format? Use json2yaml.

Use with files or stdin/stdout. Pretty-print the JSON if you want.

Requires pyyaml (via pip or easy_install), aka the python-yaml Ubuntu package.

A version of these files is available at tinyurl/json2yaml and tinyurl.com/yaml2json for you to wget or curl -L

@benkehoe
benkehoe / benktools.sty
Last active August 29, 2015 14:06
LaTeX package of handy macros
\ProvidesPackage{benktools}
% Usage:
% \usepackage{benktools}
% \benkhide <-- put this when you want to remove all
% the todos, notes, version info, etc.
% e.g., for the final version
% updates at https://gist.github.com/benkehoe/c46647134d4bbd514869
<!DOCTYPE html>
<html>
<head>
<title>Draw Polygon</title>
<script type="text/javascript" src="http://lib.ivank.net/ivank.js"></script>
<script type="text/javascript" src="http://polyk.ivank.net/polyk.js"></script>
<script type="text/javascript">
var stage, s, dragged, complete, stopClick, rmv, cent, jsonText, cvs, sbt, area, centX, centY;
var remove = false;
//dragged is set to true if a Dot is being dragged