<commit_before>#!/bin/bash

sites=(
    http://publicdomaingifs.tumblr.com/
)

cachefile="$0.cache"

usage() {
    cat <<EOD
usage: $0 [-m]
EOD
    exit 1
}

lgtm_markdown() {
    echo "[![LGTM]($(lgtm))](http://lgtm.herokuapp.com/)"
}

lgtm() {
    if [ -s $cachefile ]; then
        cat $cachefile
    else
        lgtm_nocache
    fi
}

lgtm_nocache() {
    site=${sites[$(($RANDOM % ${#sites[@]}))]}
    local id=$(curl -sL ${site}random | pup 'meta[name=twitter:image]' 'attr{content}')
    echo "http://lgtm.herokuapp.com/$id"
}

cache() {
    ( lgtm_nocache > $cachefile ) &
}

main() {
    case "$1" in
        -m)
            lgtm_markdown
            ;;
        '')
            lgtm
            ;;
        *)
            usage
            ;;
    esac
}

main $1
cache<commit_msg>-c option to send LGTM to clipboard<commit_after>#!/bin/bash

sites=(
    http://publicdomaingifs.tumblr.com/
)

cachefile="$0.cache"

usage() {
    cat <<EOD
usage: $0 [-c] [-m]
EOD
    exit 1
}

lgtm_markdown() {
    echo "[![LGTM]($(lgtm))](http://lgtm.herokuapp.com/)"
}

lgtm() {
    if [ -s $cachefile ]; then
        cat $cachefile
    else
        lgtm_nocache
    fi
}

lgtm_nocache() {
    site=${sites[$(($RANDOM % ${#sites[@]}))]}
    local id=$(curl -sL ${site}random | pup 'meta[name=twitter:image]' 'attr{content}')
    echo "http://lgtm.herokuapp.com/$id"
}

cache() {
    ( lgtm_nocache > $cachefile ) &
}

main() {
    lgtm=lgtm
    pipe=cat

    while [[ $# > 0 ]]; do
        case "$1" in
            -c)
                pipe=pbcopy
                ;;
            -m)
                lgtm=lgtm_markdown
                ;;
            *)
                usage
                ;;
        esac

        shift
    done

    eval "$lgtm | $pipe"
}

main $*
cache
{'fraction_non_alphanumeric': 0.17950169875424687, 'fraction_numerical': 0.0056625141562853904, 'mean_word_length': 1.731066460587326, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5569955', 'n_tokens_mistral': 725, 'n_tokens_neox': 690, 'n_words': 122}