The above grid shows the effect of fisheye distortion. Move the mouse to change the focal point.
#include <iostream> | |
template <typename Ret, typename Arg> | |
class Prod { | |
private: | |
Ret (*left)(Arg); | |
Ret (*right)(Arg); | |
public: | |
Prod(Ret (*l)(Arg), Ret (*r)(Arg)) { | |
this->left = l; |
// Prettier case statement, but can also return a value since it is an expression. | |
// | |
first_condition | |
? first_action() | |
: second_condition | |
? second_action() | |
: third_condition && can && (be || compound) | |
? ( | |
can(), |
""" | |
If a virtual environment is active, make sure it's being used. | |
Globally-installed console scripts use an absolute shebang path which | |
prevents them from importing packages in the virtualenv. | |
""" | |
import os | |
import os.path | |
if 'VIRTUAL_ENV' in os.environ: |
# -*- coding: utf-8 -*- | |
# <nbformat>3.0</nbformat> | |
# <codecell> | |
import json | |
import jsonld | |
import pprint | |
import rdflib | |
import rdflib_jsonld |
#!/bin/bash | |
while IFS=" " read -ra LINE; do | |
REF=${LINE[2]} | |
HEAD=`echo ${REF} | awk '{print $NF}' | awk -F/ '{print $NF}'` | |
GIT_WORK_TREE=~/${HEAD} git checkout -f ${REF} | |
source ~/${HEAD}/bin/activate | |
pip install -r ~/${HEAD}/requirements.txt | |
pip install ~/${HEAD} | |
deactivate |
For Hypothes.is, I've been using git describe
s --always
option for generating version numbers. However, Chrome apps can only have digits (and '.') in their version identifiers. For that reason, instead of ending up with 0.0.6-1371-g93b5d9d
(which is what versioneer generates for me), I've been publishing extensions that strip off the git hash.
When something goes wrong in production, the clear question is "what git hash was this extension built from?"
Here's my bash script to recover a git hash from a version like "0.0.6-1371" (in our case this means 1371 commits since v0.0.6).
It's easy: use git rev-list
to count the commits since the tag. Then, subtract from that the trailing count in our version number to get the difference. Finally, skip back that amount from HEAD (important: in topological order).
(defun balance-margins () | |
"This function balances the margins of all windows on the selected | |
frame such that the first column and the fill column are the same | |
distance from the left and right edge, respectively." | |
(walk-windows | |
(lambda (window) | |
(let* ((total-width (window-total-width window)) | |
(fringe-width (apply '+ (butlast (window-fringes window)))) | |
(scroll-bar-width (window-scroll-bar-width window)) | |
(divider-width (window-right-divider-width window)) |
selectorExtension = require('./selectorExtension') | |
CustomAnnotator = Annotator.extend(selectorExtension) | |
annotator = new CustomAnnotator(...) |
// This is our interaction point | |
position = null; | |
$(document.body).on('mouseup', function (event) { | |
}); | |
var annotator = Annotator.create({ | |
onSelection: function (event) { | |
// We have to trigger this event ourselves. | |
// Could be as simple as: |