This file contains hidden or 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/python | |
| from __future__ import print_function # Need to grab the print function from Python 3. | |
| import parsedatetime # Requires "parsedatetime" Python module | |
| from datetime import datetime | |
| import argparse | |
| argparser = argparse.ArgumentParser() |
This file contains hidden or 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/env python | |
| # ------ # | |
| # Requires notify-send: http://vaskovsky.net/notify-send/ | |
| # To link it to this script, download notify-send, | |
| # get the path of the `notify-send.exe` file, | |
| # and paste it into the "notify_send_path" variable. | |
| # ------ # | |
| # Work for 25 minutes, break for 5 minutes. |
This file contains hidden or 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/sh | |
| nvidia-smi -q | grep "Driver Version" | awk '{ print $NF }' |
This file contains hidden or 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
| import re | |
| import csv | |
| import fnmatch | |
| from os import listdir | |
| from os.path import basename, splitext | |
| file_list = [] | |
| for dir_file in listdir('.'): | |
| if fnmatch.fnmatch(dir_file, '*.log'): | |
| file_list.append(dir_file) |
This file contains hidden or 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/python | |
| import random | |
| # int((random.random() * 90000) + 10000) # Yields numbers between 10000 and 99999 | |
| def numCheck(inDict): | |
| inputLength = len(inDict) | |
| while len(inDict) == inputLength: | |
| try: |
This file contains hidden or 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
| # It's better to use [jq](https://stedolan.github.io/jq/) for this instead. | |
| # `jq '.' /path/to/jsonfile.json | less` shows a JSON file in less | |
| cat jsonfile.json | sed 's/\}, /}, \'$'\n/g' | less # Uses an old-school escape sequence to get a real newline. |
This file contains hidden or 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
| from PIL import Image, ImageDraw, ImageFilter | |
| import dialogs | |
| import console | |
| import photos | |
| assets = photos.pick_asset(title='Pick some assets', multi=True) | |
| for this_asset in assets: | |
| im = this_asset.get_image() | |
| im = im.convert('RGBA') | |
| settings = {} |
This file contains hidden or 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
| import datetime | |
| def time_code(time1, time2, label): | |
| time_difference = (time2 - time1).total_seconds() | |
| return 'Time to run ' + label + ': ' + str(time_difference) + ' seconds.' | |
| time_a = datetime.datetime.now() | |
| sleep 10 # Replace with whatever code needs to be timed. |
This file contains hidden or 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
| import csv | |
| input_csv_file = '/path/to/test_csvfile.csv' | |
| with open(input_csv_file, 'rb') as csvfile: #`with open(input_csv_file, 'r') as csvfile:` for Python 3 | |
| csv_test_bytes = csvfile.read(1024) # Grab a sample of the CSV for format detection. | |
| csvfile.seek(0) # Rewind | |
| has_header = csv.Sniffer().has_header(csv_test_bytes) # Check to see if there's a header in the file. | |
| dialect = csv.Sniffer().sniff(csv_test_bytes) # Check what kind of csv/tsv file we have. | |
| inputreader = csv.reader(csvfile, dialect) |
This file contains hidden or 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
| from datetime import datetime, timedelta | |
| today = datetime.now() | |
| date_today = datetime(today.year, today.month, today.day) | |
| day_of_the_week = date_today.weekday() | |
| date_start_delta = timedelta(-(date_today.weekday())) | |
| date_start = date_today + date_start_delta # Result should be Monday of this week. | |
| date_end_delta = timedelta(4) | |
| date_end = date_start + date_end_delta # Result should be Friday of this week. |