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
#!/bin/bash
# This script performs a git rebase across a commit that contains the changes
# generated by running a command (typically some sort of formatter; we'll use
# "formatter" to describe it from now on) on the contents of the repo; each new
# commit, after the rebase contains the contents of the corresponding original
# commit plus the effects of the command.
# This script takes two arguments: the ref containing the code to be rebased and
# the commit containing the formatter changes.
@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 November 14, 2020 10:18
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