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
| tell application "Safari" | |
| set selected to (do JavaScript "x=(function() { self.focus() ; b= self.getSelection().anchorNode.parentNode.outerHTML; return b ; })();x" in document 1) as string | |
| return selected | |
| end tell |
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 | |
| import argparse | |
| from os import path | |
| from PIL import Image, ImageDraw, ImageFilter | |
| argparser = argparse.ArgumentParser() | |
| argparser.add_argument('input_file', help='File to add faded edges to') |
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 | |
| # Thanks to http://www.devdungeon.com/content/desktop-notifications-python-libnotify | |
| import time | |
| from datetime import datetime | |
| from gi.repository import Notify | |
| Notify.init('pomodoro_linux.py') |
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 | |
| # Work for 25 minutes, break for 5 minutes. | |
| # Thanks to lukaszb for the gist at https://gist.github.com/lukaszb/5001170 | |
| import time | |
| from datetime import datetime | |
| from Foundation import NSUserNotification | |
| from Foundation import NSUserNotificationCenter |
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
| --Adapted from http://apple.stackexchange.com/questions/194567/how-can-i-use-applescript-to-type | |
| --Types text in where TypeIt4Me dare not tread (like in a VNC session). | |
| on run {input, parameters} | |
| tell application "System Events" | |
| set textToType to the clipboard | |
| delay 1 | |
| keystroke textToType | |
| end tell |
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/python | |
| for i in range(0,100,10): | |
| for j in range(0,10): | |
| print(str(i+j).rjust(3), end='') | |
| print('') |
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. |
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
| 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
| 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 = {} |