Skip to content

Instantly share code, notes, and snippets.

"""
Sphinx is hardcoded to interpret links to downloadable files relative to the root of the docs
source tree. However, the downloadable files we want to use are themselves generated at build time,
and we would therefore like them to be separate from the source. This module is a Sphinx plugin that
replaces the normal interpretation of links, causing Sphinx to look for downloads relative to a
different directory (which is set in `conf.py`).
"""
import logging
import os
@dzhu
dzhu / LICENSE
Last active April 13, 2025 18:32
Copyright 2020 Danny Zhu
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 OTHER D
@dzhu
dzhu / Xorg.8.log
Created February 8, 2017 21:57
bumblebee information
[ 21876.287]
X.Org X Server 1.18.4
Release Date: 2016-07-19
[ 21876.287] X Protocol Version 11, Revision 0
[ 21876.287] Build Operating System: Linux 4.4.0-45-generic x86_64 Ubuntu
[ 21876.287] Current Operating System: Linux dzhu-tp 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64
[ 21876.287] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-62-generic root=UUID=0513250d-a398-4c36-bc4e-605a54eb2f1e ro text
[ 21876.287] Build Date: 02 November 2016 10:06:10PM
[ 21876.287] xorg-server 2:1.18.4-0ubuntu0.2 (For technical support please see http://www.ubuntu.com/support)
[ 21876.287] Current version of pixman: 0.33.6
diff --git a/lib/awful/layout/suit/tile.lua b/lib/awful/layout/suit/tile.lua
index 9fa263ca..83f0e3cb 100644
--- a/lib/awful/layout/suit/tile.lua
+++ b/lib/awful/layout/suit/tile.lua
@@ -206,7 +206,8 @@ local function tile_group(gs, cls, wa, orientation, fact, group)
geom[x] = group.coord
geom[y] = coord
gs[cls[c]] = geom
- hints.width, hints.height = cls[c]:apply_size_hints(geom.width, geom.height)
+ hints.width, hints.height = cls[c]:apply_size_hints_with_border(geom.width, geom.height)
@dzhu
dzhu / flow_walls.py
Created April 6, 2016 17:58
Screeps map processor utility and max-flow-based wall planner
## We want to compute the minimum number of squares to make impassable (by
## adding walls/ramparts) such that all of a certain set of locations (the
## "protected" locations) are unreachable from all room exits. We model this as
## a max-flow/min-cut problem on a graph.
##
## Each passable square (swamp, plain, or exit) becomes two vertices, a "top"
## and a "bottom", with an edge of capacity 1 from the top to the bottom of each
## square. Additionally, there is an edge of infinite capacity from the bottom
## of each square to the top of each adjacent square.
##
@dzhu
dzhu / push.py
Created February 21, 2016 07:08
python Screeps push script
import hashlib
import json
import glob
import os
import requests
auth = ('EMAIL', 'PASSWORD')
def push(ptr=False):
@dzhu
dzhu / screeps.py
Last active September 19, 2024 12:14
description of the HTTP endpoints available from Screeps, and a Python wrapper to access them (requires requests library)
import json
from base64 import b64decode
from collections import OrderedDict
from cStringIO import StringIO
from gzip import GzipFile
import requests
## Python before 2.7.10 or so has somewhat broken SSL support that throws a warning; suppress it