Skip to content

Instantly share code, notes, and snippets.

@gcv
gcv / gpgd.zsh
Last active October 6, 2016 14:32
# Currently only tested on zsh.
# To install, just copy this function to your .zshrc file.
# On Mac OS, make sure you have greadlink available (install coreutils
# through Homebrew).
# Make sure you have the GnuPG binary in your path.
function gpgd() {
# Enables mounting GPG-encrypted tar files as directories. Upon
# dismount, updates the encrypted tar file.
@jberkus
jberkus / gist:6b1bcaf7724dfc2a54f3
Last active January 7, 2024 21:26
Finding Unused Indexes
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@metalivedev
metalivedev / Dockerfile-RTD
Last active January 2, 2016 04:39
Containerizing RTD. Requires 1GB of RAM to compile in a VM. This version does all the apt-get's in one layer and sets up the database. You'll still need to use ./manage.py updatepassword manually -- haven't figured out how to automate that yet.
FROM ubuntu
# Add the Universe to the repo list
RUN echo 'deb http://us.archive.ubuntu.com/ubuntu/ precise universe' >> /etc/apt/sources.list
RUN echo 'deb http://us.archive.ubuntu.com/ubuntu/ precise-updates universe' >> /etc/apt/sources.list
# You might also need redis, nginx, postgres, and celeryd to work like production RTD.
# openssh-server is optional and just makes it easier to interact with the container later.
RUN apt-get update && apt-get install -y gcc git openssh-server python-pip python-dev libxml2-dev libxslt1-dev
RUN git clone http://github.com/rtfd/readthedocs.org.git
RUN cd readthedocs.org && pip install -r pip_requirements.txt
@mgedmin
mgedmin / check_manifest.py
Last active October 14, 2015 00:08
Beginning of a tool to check Python MANIFEST.in for completeness. MOVED TO https://github.com/mgedmin/check-manifest
#!/usr/bin/python
"""Check the MANIFEST.in file in a Python source package for completeness.
Here's the plan:
This script works by building a source distribution archive (by running
setup.py sdist), then checking the file list in the archive against the
file list in version control (Subversion, Git, Mercurial, Bazaar are
supported).
Since the first check can fail to catch missing MANIFEST.in entries when
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: