This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* SETUP | |
1. Create an Application in Automator. | |
2. Add a Run AppleScript action. | |
3. Paste the content of this gist instead of the provided script skeleton. | |
4. Save the app, drag it to your dock and/or set it as the default app for | |
the filetypes of your choice using the Open With dialog in Finder. | |
NOTES ON USAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A quick reminder on how to use Promises with Node and Express in order to run potentially | |
* time-consuming jobs asynchronously (assuming the jobs are able to run in the background thanks to | |
* libuv and actually return Promises). | |
* | |
* Start the server, navigate to /startjob, then refresh a few times, the job should be in progress. | |
* You can navigate elsewhere in the "app" in other browser tabs in the meanwhile (/). After about | |
* 20s, you should get a result by refreshing the tab where you originally submitted the job. | |
* | |
* I hope this pattern will be useful e.g. for processing images with the `sharp` library (see | |
* <http://sharp.dimens.io>). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)] |
OlderNewer