Skip to content

Instantly share code, notes, and snippets.

@kopischke
kopischke / Functions.js
Last active Aug 15, 2020
Code snippets for Script actions in Airtable Automations
View Functions.js
// Utility functions for Airtable Automations
/**
* @param {string} url
* @param {Base} [forBase=base]
*/
function getTableFromURL(url, forBase) {
let root = forBase ? forBase : base
let found = url.match(/^https?:\/\/airtable.com\/(?<tableID>[^\/]+)/)
return root.getTable(found.groups.tableID)
View keybase.md

Keybase proof

I hereby claim:

  • I am kopischke on github.
  • I am kopischke (https://keybase.io/kopischke) on keybase.
  • I have a public key ASDlnW91QWJYnnfX16uSbgTz8vs6bl9Hac88FlzzZbbwjAo

To claim this, I am signing this object:

@kopischke
kopischke / alias_completion.sh
Last active Mar 23, 2020
Automatically add completion functions for aliases
View alias_completion.sh
# Automatically add completion for all aliases to commands having completion functions
function alias_completion {
local namespace="alias_completion"
# parse function based completion definitions, where capture group 2 => function and 3 => trigger
local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)'
# parse alias definitions, where capture group 1 => trigger, 2 => command, 3 => command arguments
local alias_regex="alias ([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'"
# create array of function completion triggers, keeping multi-word triggers together
View markdown2evernote.rb
#!/usr/bin/env ruby -wKU
# Adapted from Brett Terpstra’s original “Markdown to Evernote” service (http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/)
# Martin Kopischke 2011 – License: Creative Commons Attribution Share-Alike (CC BY-SA) 3.0 Unported (http://creativecommons.org/licenses/by-sa/3.0/)
# Changes: – create only one Evernote note per (Multi)Markdown input passed (instead of one per line)
# – do not choke on shell escape characters (use Tempfile instead of shell pipe for osascript)
# – default to MultiMarkdown 3 executable (instead of MMD 2 Perl script)
# – make smart typography processing optional (set SMARTY to 'false' to bypass processing;
# note smart typography cannot be disabled in MMD 3.0 and 3.0.1
# – handle both smart typography processing scripts (ie. SmartyPants.pl)