Skip to content

Instantly share code, notes, and snippets.

View codelahoma's full-sized avatar

Rod Knowlton codelahoma

View GitHub Profile
@codelahoma
codelahoma / grok_vi.mdown
Created October 12, 2017 20:29 — forked from nifl/grok_vi.mdown
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@codelahoma
codelahoma / gifenc.sh
Created May 13, 2017 13:46 — forked from dplesca/gifenc.sh
#gif with text overlay #generator using #ffmpeg - inspired by http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
#!/bin/bash
#parameters:
# $1 - mp4 url
# $2 - start time in format hh:mm:ss.mic
# $3 - duration in seconds
# $4 - text for gif overlay
# $5 - output file without extension
if [ "$#" -ne 5 ]
then
echo "Usage: gifenc.sh \$1 \$2 \$3 \$4 \$5
@codelahoma
codelahoma / omdb.sh
Last active April 30, 2017 22:18
Find in OMDB shell function
# Example:
#
# >fmdb jaws
#
# Jaws (1975)
# Jaws 2 (1978)
# Jaws: The Revenge (1987)
# Jaws 3-D (1983)
# The Making of Steven Spielberg's 'Jaws' (1995)
# In the Jaws of Life (1984)
<!-- ,M M~
?MIM MM.
MM8MD.IMM$
~M~ :M+
~M D+
M M,
M M
? M .
M $
Z Z
@codelahoma
codelahoma / diagram.xhtml
Last active October 16, 2016 18:06
Visual Format Language as EBNF and Railroad Diagram
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><script type="text/javascript" src="chrome-extension://kajfghlhfkcocafkcjlajldicbikpgnp/catcher.js">&lt;!-- script injected by Request Maker --&gt;</script>
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="generator" content="Railroad Diagram Generator 1.45.1338" /><style type="text/css">
::-moz-selection
{
color: #FFFCF0;
background: #0F0C00;
}
::selection
@codelahoma
codelahoma / xcode-todo-fixme-as-warning.sh
Created October 15, 2016 19:11
Highlight TODO and FIXME as warnings in Xcode 8 (add as script build phase)
TAGS="TODO:|FIXME:"
SKIPDIRS="/Carthage"
find "${SRCROOT}/" -type f \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 \
| xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" \
| grep -v "$SKIPDIRS" \
| perl -p -e "s/($TAGS)/ warning: \$1/"
@@ -50,7 +50,7 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import org.apache.cordova.CallbackContext;
-import org.apache.cordova.Config;
+import org.apache.cordova.Whitelist;
import org.apache.cordova.CordovaArgs;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
@@ -143,6 +143,7 @@ public class InAppBrowser extends CordovaPlugin {
@codelahoma
codelahoma / gist:71d648a3b37061e4d15d
Last active August 29, 2015 14:25
promiseForPath - function for use with Q library
// Works like underscore-contrib's getPath function.
// Takes a promise that will resolve to an object and a dot notation string specifying a path.
//
// Cannot know if path exists in resolved value - returned promise will reject with a TypeError if you
// specify a subkey of a nonexistent key, and undefined for a single
// nonexistent key.
function promiseForPath(promise, path) {
var k = path.split('.');
return k.reduce(function(memo, item){
@codelahoma
codelahoma / GoogleSearch.py
Last active August 29, 2015 14:14 — forked from omz/GoogleSearch.py
GoogleSearch
# Google Search for Pythonista (iOS)
# Searches Google and copies the first result to the clipboard as
# a Markdown link in the form [title](url).
#
# Inspired by Brett Terpstra's SearchLink:
# http://brettterpstra.com/searchlink-automated-markdown-linking-improved/
import clipboard
def google(terms):

Detecting "Nothing" in Workflow.is

The iOS app Workflow is the greatest thing since whatever the last great thing was, and I am diving in head first.

One of the first problems I've run into is the inability of the If action to detect the absence of a string.

Why would you want to?

Let's say you have a workflow that's processing a JSON result that has optional fields, and there's something you'd like to do, but only if a certain key is present.