Skip to content

Instantly share code, notes, and snippets.

View dlukes's full-sized avatar

David Lukes dlukes

View GitHub Profile
@dlukes
dlukes / kontext-interface-layout-switcher.js
Last active August 29, 2015 14:15
A Greasemonkey/Tampermonkey userscript to tweak the layout of the KonText corpus concordancer (https://kontext.korpus.cz).
// ==UserScript==
// @name KonText Interface Layout Switcher
// @namespace https://trnka.korpus.cz/~lukes
// @version 0.1.2
// @description turns the KonText topbar into a sidebar, adds a query box
// @author David Lukeš
// @match https://kontext.korpus.cz/*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==UserScript==
// @name KonText vertical menu v2
// @namespace https://trnka.korpus.cz/~lukes
// @version 0.1
// @description enter something useful
// @author David Lukeš
// @match https://kontext.korpus.cz/*
// @grant none
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @require https://code.jquery.com/jquery-1.11.2.min.js
@dlukes
dlukes / kontext-interface-layout-switcher-enhanced.js
Last active August 29, 2015 14:21
An improved version of my Greasemonkey/Tampermonkey userscript to tweak the layout of the KonText corpus concordancer (https://kontext.korpus.cz).
// ==UserScript==
// @name KonText Interface Layout Switcher
// @namespace https://trnka.korpus.cz/~lukes
// @version 1.0.0
// @description turns the KonText topbar into a sidebar, adds a query box
// @author David Lukeš
// @match https://kontext.korpus.cz/*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
@dlukes
dlukes / stretchy_div.html
Last active February 3, 2016 19:44
A stretchy div between other divs on one line.
<!-- How to have a div stretch between divs on the left and right. Useful e.g. for -->
<!-- Bootstrap navbar et al. -->
<style>
.inner-navbar {
border: 2px solid black;
padding: 5px;
width: 100%;
}
.left {
@dlukes
dlukes / mysql_collation.py
Last active September 1, 2016 12:42
Case-insensitive, diacritic-sensitive collation with MySQL demo
# Case-insensitive, diacritic-sensitive collation with MySQL demo
#
# Dependencies -- install ``python3``, then:
#
# $ pip3 install --user pymysql sqlalchemy
#
# Replace <user>, <passwd> and <db> in the create_engine() URL with suitable
# values corresponding to your local MySQL setup.
#
# Usage:
@dlukes
dlukes / this_regular_vs_arrow_functions.js
Last active January 25, 2017 12:09
A review of `this` in regular vs. arrow functions in JavaScript.
/* With regular functions, `this` is bound purely depending on how the function is called. If it's
* bound to an object (either explicitly or via the `instance.funcName()` sugar), `this` refers to
* that object. Otherwise, it's `undefined` (or `window`, depending on your exact environment and
* whether `"use strict";` is in effect).
*
* In particular, it doesn't matter whether the function is attached to the object itself as a
* property, i.e. each instance has its own version of the function created during initialization,
* (see `Class2`), or whether it exists on the object's `prototype` as a method and all instances
* share it (see `Class1`). `this` is always resolved dynamically, i.e. depending on the call site.
* Neither of these is well suited for yanking out of the context of the original object and using
#!/usr/bin/env python3
import time
import subprocess as sp
import concurrent.futures as cf
start = time.time()
with cf.ThreadPoolExecutor() as e:
futures = [e.submit(sp.check_output, f"sleep 2s && echo Done {i}.", shell=True) for i in range(3)]
@dlukes
dlukes / cnc-toolbar-links.js
Created March 4, 2017 07:59
CNC Toolbar Links
@dlukes
dlukes / kontext-v0.9.x-queryBox.js
Last active April 3, 2017 09:05
kontext-v0.9.x-queryBox.js
// ==UserScript==
// @name KonText Interface Layout Switcher
// @namespace https://trnka.korpus.cz/~lukes
// @version 3.2.0 (for KonText v0.9.x)
// @description Adds a quick query box to KonText above the concordance
// @author David Lukeš
// @match https://kontext.korpus.cz/*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
@dlukes
dlukes / explicitly_installed.py
Created November 6, 2017 10:38
List packages explicitly installed with pacman or the AUR on Arch Linux
#!/usr/bin/env python3
"""List packages explicitly installed with pacman or pacaur."""
import re
from collections import namedtuple
from subprocess import check_output
Package = namedtuple("Package", "date name")