Skip to content

Instantly share code, notes, and snippets.

View fractaledmind's full-sized avatar

Stephen Margheim fractaledmind

View GitHub Profile
@fractaledmind
fractaledmind / Evernote2HTML
Created February 4, 2014 16:25
Get the HTML contents of the selected Evernote note
tell application "Evernote"
set Evernote_Selection to selection
if Evernote_Selection is {} then display dialog "Please select a note."
set noteLink to ""
repeat with i from 1 to the count of Evernote_Selection
set noteHTML to HTML content of item i of Evernote_Selection
end repeat
end tell
@fractaledmind
fractaledmind / MMDLink
Created February 5, 2014 00:53
Bookmarklet to send webpage title, url, and selected text to Drafts in MMD format
@fractaledmind
fractaledmind / applescript_rgb_color
Created March 28, 2014 16:33
RGB color codes for Apple's color palette and Crayon palette.
set {black, blue, brown, cyan, green, magenta, orange, purple, red, yellow, white} to {{0, 0, 0}, {0, 0, 65535}, {39321, 26214, 13107}, {0, 65535, 65535}, {0, 65535, 0}, {65535, 0, 65535}, {65535, 32768, 0}, {32768, 0, 32768}, {65535, 0, 0}, {65535, 65535, 0}, {65535, 65535, 65535}}
set {cantaloupe, honeydew, spindrift, sky, lavender, carnation, licorice, snow, salmon, banana, flora, ice, orchid, bubblegum, lead, mercury, tangerine, lime, sea_foam, aqua, grape, strawberry, tungsten, silver, maraschino, lemon, spring, turquoise, blueberry, iron, magnesium, mocha, fern} to {{65535, 52428, 26214}, {52428, 65535, 26214}, {26214, 65535, 52428}, {26214, 52428, 65535}, {52428, 26214, 65535}, {65535, 28527, 53199}, {0, 0, 0}, {65535, 65535, 65535}, {65535, 26214, 26214}, {65535, 65535, 26214}, {26214, 65535, 26214}, {26214, 65535, 65535}, {26214, 26214, 65535}, {65535, 26214, 65535}, {6425, 6425, 6425}, {59110, 59110, 59110}, {65535, 32896, 0}, {32896, 65535, 0}, {0, 65535, 32896}, {0, 32896, 65535}, {32896, 0, 6553
# Banner-style (default)
from Foundation import NSUserNotification, NSUserNotificationCenter
def notify(title, subtitle, text):
notification = NSUserNotification.alloc().init()
notification.setTitle_(str(title))
notification.setSubtitle_(str(subtitle))
notification.setInformativeText_(str(text))
notification.setSoundName_("NSUserNotificationDefaultSoundName")
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
import os, os.path, sys, urllib2, requests
class PyPiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def _chunk_report(bytes_so_far, chunk_size, total_size):
if (total_size != None):
@fractaledmind
fractaledmind / SenteQuery
Last active August 29, 2015 14:01
Initial foray into Sente port of ZotQuery. For 100 items, currently takes appr. 10 seconds
#!/usr/bin/python
# encoding: utf-8
from __future__ import unicode_literals
import re
import json
#import sqlite3
import os.path
import subprocess
from collections import OrderedDict
@fractaledmind
fractaledmind / alfred_check_workflow
Created May 19, 2014 18:02
Alfred, check for workflow by name
#!/usr/bin/python
# encoding: utf-8
import os
import plistlib
def check_for_workflow(name):
"""Check if specified workflow name exists"""
workflows_dir = os.path.dirname(os.getcwd())
all_wfs = os.walk(workflows_dir).next()[1]
found = False
@fractaledmind
fractaledmind / pip_installer
Created May 29, 2014 00:44
Install `pip` from GitHub
import os
import sys
import urllib2
from zipfile import ZipFile
from StringIO import StringIO
LIB_PATH = os.path.expanduser("~/Library/Application Support/Alfred 2/" \
"Workflow Data/alfred.bundler-aries/assets/python/")
def _install_pip():
@fractaledmind
fractaledmind / alfred_bundler
Last active August 29, 2015 14:01
Version 1.1 of basic bundler methods for Alfred
#!/usr/bin/python
# encoding: utf-8
from __future__ import unicode_literals
import os
import imp
import sys
import json
import shutil
import base64
@fractaledmind
fractaledmind / packal_update_checker.py
Created June 4, 2014 19:36
Check if Alfred workflow has updated version on Packal
import os
import re
import urllib2
import plistlib
import xmltodict
import subprocess
def as_run(ascript):
"""Run the given AppleScript and return the standard output and error."""