Skip to content

Instantly share code, notes, and snippets.

@jonls
jonls / texchem2pdf
Created May 4, 2017 19:14
Generate PDF of XeTeX typeset chemical formula
#!/bin/bash
# Generate PDF of XeTeX typeset chemical formula.
xelatex <<EOF
\documentclass[border=1pt]{standalone}
\usepackage{unicode-math}
\setmathfont{Cambria Math}
\usepackage{chemformula}
\setchemformula{font-spec=Cambria}
\begin{document}
\ch{$1}
@jonls
jonls / texmath2pdf
Created May 4, 2017 19:13
Generate PDF of XeTeX typeset math
#!/bin/bash
# Generate PDF of XeTeX typeset math.
xelatex <<EOF
\documentclass[border=1pt]{standalone}
\usepackage{unicode-math}
\setmathfont{Cambria Math}
\begin{document}
$\displaystyle
$1
$
@jonls
jonls / glpk_clean.h
Created September 18, 2015 20:42
swiglpk 1.2.3 bdist_wheel failure (Linux)
/* glpk.h (GLPK API) */
/***********************************************************************
* This code is part of GLPK (GNU Linear Programming Kit).
*
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
* 2009, 2010, 2011, 2013, 2014 Andrew Makhorin, Department for Applied
* Informatics, Moscow Aviation Institute, Moscow, Russia. All rights
* reserved. E-mail: <mao@gnu.org>.
*
@jonls
jonls / macports_select.py
Created September 11, 2015 15:16
Ansible module for MacPorts select
#!/usr/bin/env python
import pipes
from ansible.module_utils.basic import *
def query_group(module, port_path, group):
rc, out, err = module.run_command('{} select --list {}'.format(
pipes.quote(port_path), pipes.quote(group)))
@jonls
jonls / dark-mode-hook.sh
Created April 25, 2015 14:05
OS X dark mode hook for Redshift. Set DARK_MODE to the path to https://github.com/sindresorhus/dark-mode
#!/bin/sh
DARK_MODE=/path/to/dark-mode
case $1 in
period-changed)
case $3 in
daytime)
$DARK_MODE --mode Light
;;
night)
$DARK_MODE --mode Dark
@jonls
jonls / doilinks.py
Last active March 20, 2023 21:06
DOI role for Sphinx
@jonls
jonls / geoclue2_test.py
Created May 9, 2014 19:30
Geoclue2 test
#!/usr/bin/env python
import dbus
if __name__ == '__main__':
bus = dbus.SystemBus()
manager_obj = bus.get_object('org.freedesktop.GeoClue2', '/org/freedesktop/GeoClue2/Manager')
manager = dbus.Interface(manager_obj, 'org.freedesktop.GeoClue2.Manager')
client_path = manager.GetClient()
@jonls
jonls / brain-wallet-many.html
Last active April 18, 2018 22:43
HTML/Javascript generator of many bitcoin brain wallets (based on bitaddress.org).
<!doctype html>
<html>
<head>
<!--
Donation Address: 1NiNja1bUmhSoTXozBRBEtR8LeF9TGbZBN
Notice of Copyrights and Licenses:
***********************************
The bitaddress.org project, software and embedded resources are copyright bitaddress.org.
The bitaddress.org name and logo are not part of the open source license.
[globals]
version=v0.1_pre20121216-8-g500ebf9
map.col_size=6
map.row_size=6
split=0
update_map_initial_pos=24,8
cfg.left=57
cfg.right=57
game_type=0
game_tick=-63176704
@jonls
jonls / 14.png
Created November 18, 2012 14:31
Bugs 2012-11-18
14.png