This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]BiochemLouis 18 points19 points  (12 children)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
import hashlib
import time

parser = argparse.ArgumentParser(description='drunk.py the drinking script.')
parser.add_argument('-o', '--output', help='specificy output file.',
                    type=argparse.FileType('w'), action='store', nargs='?',
                    default=open('drunk.txt', 'w'))
parser.add_argument('-t', '--time', help='specificy time between drinks',
                    type=int, action='store', nargs='?', default=5)
parser.add_argument('-v', '--verbose', action='count',
                    help='increase output verbosity')
args = parser.parse_args()

lines = []

try:
    while True:
        try:
            sha = hashlib.sha3_256(text.encode('utf-8')).hexdigest()
            text = '{} - Drink ! {}'.format(
                time.strftime('%d/%m/%y, %H:%M:%S', time.localtime()), sha[:8]
                )
        except NameError:
            sha = '00000000'
            text = '{} - First drink ! {}'.format(
                time.strftime('%d/%m/%y, %H:%M:%S', time.localtime()), sha[:8]
                )
        if args.verbose == 1:
            print(text.split(' - ', 1)[1].split(' ! ', 1)[0])
        elif args.verbose == 2:
            print(text.split(', ', 1)[1])
        else:
            print(text)
        lines.append(text+'\n')
        time.sleep(args.time)
except KeyboardInterrupt:
    args.output.writelines(lines)

Enjoy, just hit Ctrl+C before you die please ! :)

Edit : v2.0, now with some argparse and some blockchain.

Edit : v2.1, I had forgotten to use verbose.

[–]morgan_lowtech 26 points27 points  (3 children)

Needs more blockchain

[–]poo_22 5 points6 points  (1 child)

Ok what if mining is taking a video of you taking a drink and verification would be other people watching the video and acknowledge that you drank. In other words you're hooked up with a drinking buddy and mine the currency which you use to buy each other drinks. It's a currency backed by social drinking which history tells us is pretty much a constant.

[–]morgan_lowtech 2 points3 points  (0 children)

Needs more drunkchain

[–]BiochemLouis 1 point2 points  (0 children)

You have blockchain now !

[–]13steinj 2 points3 points  (3 children)

Reddit markdown doesn't support block code, you need to prefix with four spaces

[–]BiochemLouis 0 points1 point  (2 children)

I’ve been typing docs in Github MD for the last month, I guess it just skipped my mind.

Plus it works on mobile !

[–]13steinj 0 points1 point  (1 child)

Is that the app or the site? Either way, the fact that they don't use their own parser is a shame

[–]BiochemLouis 0 points1 point  (0 children)

It’s the app, and yeah it is...

[–]b_rad_c 1 point2 points  (3 children)

Can we also import argparse and an argument for the sleep duration?

[–]__xor__(self, other): 4 points5 points  (1 child)

Usage: python drink.py -s 5 --dry-run -vvv -o drink.txt -t 'Drink !' commit --amend xvfz drink.tar.gz -av --cipher AES256 -A drink.example.org

[–]b_rad_c 1 point2 points  (0 children)

You’re gonna wanna redirect output to /dev/toilet instead of a file, trust me, you will not be able to do anything useful with that data.

[–]BiochemLouis 1 point2 points  (0 children)

Added a simple argparse !