Skip to content

Instantly share code, notes, and snippets.

import re
import os
import sys
import webbrowser
from dropboxlogin import get_client
client = get_client()
f = client.get_file('/path/to/Library.txt')
books = f.read().split('\n')
#!/usr/bin/env python3
from os.path import expanduser
from urllib import request
from urllib import parse
import json
import sys
API_URL = "https://feedwrangler.net/api/v2/"
@macolyte
macolyte / today_i_learned.py
Last active December 11, 2015 21:39
Learn something new every day with Pythonista
from datetime import date
import webbrowser
import console
def main():
result = console.alert("Today I Learned", "Choose your path", "reddit", "today", "random")
today = date.today().strftime("%B_%d")
urls = ["http://www.reddit.com/r/todayilearned", ("http://en.wikipedia.org/wiki/%s" % today), "http://en.wikipedia.org/wiki/Special:Random"]
if [ $# -lt 1 ]; then
echo "No items to add"
else
osascript - "$@" <<END
on run argv
repeat with i from 1 to (count of argv)
try
tell application "Reminders"
tell list "Shared"
make new reminder with properties {name: (item i of argv)}
@macolyte
macolyte / pinboard_reading_list.py
Created November 15, 2012 21:52
pinboard_reading_list
import os
import markdown
import requests
import webbrowser
pinToken = 'Put your Pinboard API token here'
pinAPI = 'api.pinboard.in/v1/'
pinGet = 'posts/all'
pinURL = 'https://' + pinAPI + pinGet + '?auth_token=' + pinToken + '&toread=yes&format=json'
@macolyte
macolyte / adn_suggestions.py
Created October 13, 2012 12:55
ADN Follower suggestions
import re, urllib, operator
from collections import defaultdict
USERNAME = raw_input("Get suggestions for: ")
CUTOFF = 3
pattern = re.compile(r'<span class="username"><a href="/\w+">(?P<name>\w+)</a></span>')
suggestions = defaultdict(int)
def find_followers(user):
@macolyte
macolyte / gist:3676688
Created September 8, 2012 16:21
Chrome Tabs to Evernote
set url_list to {}
set the date_stamp to ((the current date) as string)
set NoteTitle to "URL List from Chrome Tabs on " & the date_stamp
tell application "Google Chrome"
activate
set chromeWindow to window 1
repeat with w in chromeWindow
try
repeat with t in (tabs of w)
set TabTitle to (title of t)
@macolyte
macolyte / log_battery_status.py
Created July 31, 2012 12:15
Log Android Battery Status
import android
import time
from datetime import date, datetime
def log_battery_status(droid):
"""Log battery percentage"""
droid.batteryStartMonitoring()
battery = 0
while not battery:
battery = droid.batteryGetLevel().result
@macolyte
macolyte / Instant_Safari_Porn_Mode.scpt
Created March 14, 2012 21:31
Instant Safari Porn Mode
tell application "Safari" to set theURL to URL of current tab of window 1
if theURL contains "some unique part of your URL" then
tellapplication "Safari"
closecurrent tab ofwindow1
endtell
set_private_browsing()
else
set_private_browsing()
tellapplication "Safari"
makenew tabinwindow1
@macolyte
macolyte / send_to_marsedit.scpt
Created January 17, 2012 15:28
Send to MarsEdit from Evernote
tell application "Evernote"
synchronize
set the_Selection to selection
set the_Title to title of (item 1 of the_Selection)
set the_HTML to HTML content of (item 1 of the_Selection)
set the_Text to do shell script "echo " & quoted form of the_HTML & space & "| textutil -convert txt -stdin -stdout"
set the_Tags to {}