Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import json
from pathlib import Path
import sys
REPO_PATH = Path(__file__).parent.parent
sys.path.insert(0, str(REPO_PATH))
from keyboards import get_keyboards, Keyboard
@nickcoutsos
nickcoutsos / vpsql
Last active October 11, 2017 20:07
psql via vagrant ssh with help from knex.js
#!/usr/bin/env node
// Usage: vpsql [<environment>] [-- [<psql args>]]
//
// This script looks up the appropriate PostgreSQL database information in your
// local Vagrant development environment and opens a psql session via the
// vagrant ssh command. Without specifying the name of a database (as per your
// knexfile) it will default to "development" or "dev" (whichever exists). In
// addition to that you can pass arbitrary arguments through to the psql command
// by including them after "--".
@nickcoutsos
nickcoutsos / jira-markdown-converter.user.js
Created March 14, 2017 01:43
A userscript to add a Jira-Markdown converter to Jira text fields
// ==UserScript==
// @name JIRA Markdown Converter
// @namespace https://nickcoutsos.github.io/
// @version 0.1
// @description Add context menu action to convert text in a field to/from Github Flavored Markdown
// @author Nick Coutsos
// @match https://*.atlassian.net/*
// @require https://raw.githubusercontent.com/FokkeZB/J2M/master/src/J2M.js
// ==/UserScript==
@nickcoutsos
nickcoutsos / mdns_util.py
Created November 30, 2013 05:50
A wrapper class to simplify working with pybonjour in tornado.
"""
mdns_util
Provides a class to wrap pybonjour functionality and references to work
with Tornado's IOLoop for event handling.
Sample usage:
>>> from mdns_util import MDNS
>>> from tornado.ioloop import IOLoop
...
@nickcoutsos
nickcoutsos / browse_and_resolve.py
Created November 30, 2013 02:39
Simplified versions of the pybonjour examples. These use a single event loop for the chained asynchronous callbacks and include some extra comments to explain what's going on.
import select
import sys
from pybonjour import (kDNSServiceErr_NoError,
kDNSServiceFlagsAdd,
DNSServiceResolve,
DNSServiceBrowse,
DNSServiceProcessResult)
regtype = sys.argv[1]
timeout = 5
@nickcoutsos
nickcoutsos / bookmarklet.js
Created February 19, 2012 03:17
Timestamp parser bookmarklet. Highlight a timestamp (or any number) and use the bookmarklet to display it parsed as a date and time, in your locale using your browser's timezone and UTC.
javascript:(function(){findSelectionDocument=function(w){if(w.document.getSelection().toString().length>0){return w.document;}for(var i=0;i<w.frames.length;i++){var doc=findSelectionDocument(w.frames[i]);if(doc){return doc;}}return null;};doc=findSelectionDocument(window)||document;timestamp=doc.getSelection().toString().trim();c=doc.getElementById("_canvas");if(c)return;c=doc.createElement("div");c.id="_canvas";c.setAttribute("style","position:fixed;z-index:100;background-color:rgba(25,25,25,.90);top:0px;left:0px;height:100%;width:100%;text-align:center;font-family:monospace, sans-serif;font-size:12px;");c.onclick=function(){this.parentNode.removeChild(this);};w=doc.createElement("div");w.setAttribute("style","background-color:white;padding:20px;margin:100px auto 0;display:inline-block;border-radius:10px;text-align:left;box-shadow:5px 8px 24px -10px black;");w.onclick=function(){event.stopPropagation();};t=doc.createElement("table");t.setAttribute("style","border-collapse:separate;border-spacing:20px 4px;");