Skip to content

Instantly share code, notes, and snippets.

@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)