This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Lists do | |
def len([]), do: 0 | |
def len([ _head | tail ]), do: 1 + len(tail) | |
def sum([]), do: 0 | |
def sum([h | t]), do: h + sum(t) | |
def double([]), do: [] | |
def double([head | tail ]), do: [2*head | double(tail)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bottles | |
def verse(number_of_bottles) | |
first_line(number_of_bottles) << "\n" << second_line(number_of_bottles) << "\n" | |
end | |
def verses(number_of_bottles_start, number_of_bottles_end) | |
number_of_bottles_start.downto(number_of_bottles_end).map do |number_of_bottles| | |
verse(number_of_bottles) | |
end.join("\n") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! Gotconvert() abort | |
silent g/^\D/d | |
silent g/^$/d | |
silent %s/\v^(\d)x (.+)/\1\2 | |
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check out the individual writing scripts here: | |
# http://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/ | |
# red is wrapper for the fish utility "cprintf" that uses `cprintf "<fg:red>%s</fg>" "Weasel words:"` | |
function proof --description 'Check writing for dups, passive voice and weasel words' | |
red "Weasel words:" | |
weasel $argv | |
red "Passive voice:" | |
passive $argv | |
red "duplicates:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use AppleScript version "2.4" -- Yosemite (10.10) or later | |
use scripting additions | |
use O : script "omnifocus" | |
on main(argv) | |
tell application "OmniFocus" | |
tell default document | |
set saveTID to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to {" "} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Dornishman’s wife was as fair as the sun, | |
and her kisses were warmer than spring. | |
But the Dornishman’s blade was made of black steel, | |
and its kiss was a terrible thing. | |
The Dornishman’s wife would sing as she bathed, | |
in a voice that was sweet as a peach, | |
But the Dornishman’s blade had a song of its own, | |
and a bite sharp and cold as a leech. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
find ~ -maxdepth 1 -type f -not -name '.*' -exec mv {} ~/Desktop \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
BEGIN { | |
cmd="uptime" | |
cmd | getline output | |
if (output ~ /up ([7-9]|[[:digit:]][[:digit:]]) days/) { | |
system("osascript -e \'tell application \"Omnifocus\" to parse tasks into default document with transport text \"Restart iMac! @home ::misc //"output"\"\'") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prepend -d "Prepends argv[1] to argv[-1]" | |
set -l args $argv[2..-1] | |
set -l text "$argv[1]" | |
for arg in $args | |
echo '' > $arg | |
sed -i -e '1i\ | |
'"$text" $arg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use AppleScript version "2.4" -- Yosemite (10.10) or later | |
use scripting additions | |
use framework "Foundation" | |
# classes, constants, and enums used | |
property NSCaseInsensitiveSearch : a reference to 1 | |
property NSString : a reference to current application's NSString | |
set taskList to {} |