Skip to content

Instantly share code, notes, and snippets.

View mgedmin's full-sized avatar

Marius Gedminas mgedmin

View GitHub Profile
@mgedmin
mgedmin / rebuild-vim.sh
Last active December 31, 2019 13:56
Script I use to build the latest Vim on Ubuntu
#!/bin/sh
set -e
COMPILED_BY="Marius Gedminas <[email protected]>"
FEATURES=
FEATURES="$FEATURES --with-features=huge" # yum, features
FEATURES="$FEATURES --enable-multibyte" # vim is *crippled* without this!
# (BTW 'big' implies this)
FEATURES="$FEATURES --enable-pythoninterp" # most of my plugins use this
FEATURES="$FEATURES --enable-rubyinterp" # Command-T wants this
# add-apt-repository ppa:pov/ppa
You are about to add the following PPA to your system:
More info: https://launchpad.net/~pov/+archive/ppa
Press [ENTER] to continue or ctrl-c to cancel adding it
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
@mgedmin
mgedmin / apache.conf
Last active December 25, 2015 12:39
REMOTE_USER authentication for Sentry 6.3.0
WSGIDaemonProcess sentry display-name=wsgi-sentry user=sentry group=sentry processes=1 threads=4
WSGIScriptAlias / /path/to/sentry.wsgi
<Location />
WSGIApplicationGroup %{GLOBAL}
WSGIProcessGroup sentry
AuthType Basic
AuthName "sentry"
AuthUserFile /path/to/htpasswd
Require valid-user
</Location>
@mgedmin
mgedmin / StartSSL.md
Last active October 22, 2023 07:52
Free StartSSL.com SSL certificate HOWTO

How to get a free StartSSL.com SSL certificate

I'm writing this up from memory, so errors may appear.

This has been updated to use SHA256 certificates.

Start

  1. Go to http://www.startssl.com/
  2. Click on 'Control Panel'
#!/usr/bin/python
import hashlib, time
try:
from urllib.request import urlopen
except ImportError:
from urllib import urlopen
url = 'https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.10.1.tar.gz'
md5sum_expected = '3a04aa2b32c76c83725ed4d9918e362e'
response = urlopen(url)
@mgedmin
mgedmin / ppa-gtimelog-copy-packages.py
Created November 28, 2013 09:16
Automate PPA package copies, version 2.
#!/usr/bin/python
"""Copy published precise PPA packages to quantal raring saucy.
Typical usage:
- build a gtimelog package for precise
- dput ppa:gtimelog-dev gtimelog_0.8.1-0ppa0_source.changes
- wait for it to be built
- run ppa-gtimelog-copy-packages
@mgedmin
mgedmin / gist:8044562
Last active December 31, 2015 21:09
gnome-shell deadlocked on me, a couple of minutes after I unlocked the session
# gdb $(which gnome-shell) $(pidof gnome-shell)
...
(gdb) thread apply all bt
Thread 7 (Thread 0x7f2eeb7d0700 (LWP 12426)):
#0 0x00007f2efbb69f7d in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007f2efc0a96a4 in g_main_context_poll (priority=2147483647, n_fds=1, fds=0x7f2ee40010e0, timeout=-1, context=0x2367a30)
at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:4006
@mgedmin
mgedmin / gist:8559853
Last active January 4, 2016 03:09
curses.setupterm() in a doctest
mg@platonas: ~/src/new-zope-order/zope.testrunner [git:master $=] $ cat doctest.txt
>>> import curses
>>> curses.setupterm()
mg@platonas: ~/src/new-zope-order/zope.testrunner [git:master $=] $ python -m doctest doctest.txt
**********************************************************************
File "doctest.txt", line 2, in doctest.txt
Failed example:
curses.setupterm()
Exception raised:
@mgedmin
mgedmin / gist:8686551
Created January 29, 2014 12:01
DP unplug at about 13:49:xx, DP plug a bit after 13:50:05, ran 'xrandr' to force detection a few seconds later
$ wc drm.log
70167 933724 8223892 drm.log
$ < drm.log grep -v 'drm:drm_ioctl\|drm:drm_calc_vbltimestamp_from_scanoutpos\|drm:drm_wait_vblank\|drm:drm_queue_vblank_event\|drm:drm_handle_vblank_events\|more than one pipe active, disabling compression\|drm:drm_framebuffer_reference\|drm:drm_framebuffer_unreference' | wc -l
678
$ < drm.log grep -v 'drm:drm_ioctl\|drm:drm_calc_vbltimestamp_from_scanoutpos\|drm:drm_wait_vblank\|drm:drm_queue_vblank_event\|drm:drm_handle_vblank_events\|more than one pipe active, disabling compression\|drm:drm_framebuffer_reference\|drm:drm_framebuffer_unreference'
Jan 29 13:49:09 platonas kernel: [ 1990.399397] [drm:drm_vm_close_locked], 0x7fb9dcbd2000,0x00009000
Jan 29 13:49:09 platonas kernel: [ 1990.399438] [drm:drm_vm_close_locked], 0x7fb9dcbc9000,0x00009000
Jan 29 13:49:11 platonas kernel: [ 1992.815825] [drm:intel_crtc_cursor_set], cursor off
@mgedmin
mgedmin / gist:8936596
Last active August 29, 2015 13:56
Attempt to write a smart super() snippet for UltiSnips
snippet super "super()" !b
`!p
# Set a fallback completion first
# snip.rv = 'super(${1:ClassName}, self).${2:method}(' <-- does not work
snip.rv = 'super('
import vim
# this needs pythonhelper.vim
tag = vim.eval('TagInStatusLine()')
if tag:
# pythonhelper.vim's TagInStatusLine() returns '[in SomeClass.some_method (method)]'