Skip to content

Instantly share code, notes, and snippets.

@cahna
cahna / add-pathogen-submodules.sh
Last active March 3, 2017 11:13
manage installed pathogen plugins as git submodules within dofiles repo
# cd into your dotfiles repo and run this to add all of your
# installed pathogen plugins as submodules of your dotfiles repo:
ls ~/.vim/bundle \
| xargs -I% echo "grep -m1 -oP 'https[^\ ]+' <(cd ~/.vim/bundle/% && git remote -v show)" \
| bash \
| xargs -n1 git submodule add
@cahna
cahna / clever-one-liner.sh
Last active December 31, 2015 02:29
Clever: avg students/section (one-liner demo)
# Dependency: http://stedolan.github.io/jq/
jq '{total_districts: .[].count, students: [ .[][].data.students | length ]} | .total_students = reduce .students[] as $i (0; . + $i) | .total_students / .total_districts' <(curl -s -u DEMO_KEY: https://api.getclever.com/v1.1/sections) 2>/dev/null
@cahna
cahna / sub_palindrome.lua
Last active December 26, 2015 04:08
For a given string, find the longest palindrome that is a sub-string of the original string (ignoring whitespace)
#!/usr/bin/env luajit
local string = string
local socket = require 'socket'
--- Returns the character at index i (just some syntactic sugar for str:gsub(i,i))
-- @usage ('foobar'):c(3) == 'o' -- True
-- @string i Index of character within string
-- @returns Character at index i within string
function string:c(i)