This file contains 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
# A simple Evernote API demo script that lists all notebooks in the user's | |
# account and creates a simple test note in the default notebook. | |
# | |
# Before running this sample, you must fill in your Evernote developer token! | |
# | |
# This sample is part of the Evernote SDK and has been modified slightly for | |
# Pythonista, to take advantage of the clipboard and PIL modules. | |
# If there is an image in the clipboard when the script is run, it is attached | |
# to the sample note. |
This file contains 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
# | |
# Hydrogen is a lightweight GUI framework for Pythonista | |
# | |
# Hydrogen - https://gist.github.com/BashedCrab/5924965 | |
# | |
# HydrogenLayouts - https://gist.github.com/BashedCrab/6103019 | |
# | |
# HydrogenDemo - https://gist.github.com/BashedCrab/5953776 | |
# |
This file contains 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
# This script adds a "Webclip" shortcut to your homescreen. | |
# The shortcut can be used to open a web page in full-screen mode, | |
# or to launch a custom URL (e.g. a third-party app). | |
# You'll be asked for a title, a URL, and an icon (from your camera roll) | |
import plistlib | |
import BaseHTTPServer | |
import webbrowser | |
import uuid | |
from io import BytesIO |
This file contains 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
# IMPORTANT SETUP INSTRUCTIONS: | |
# | |
# 1. Go to http://www.dropbox.com/developers/apps (log in if necessary) | |
# 2. Select "Create App" | |
# 3. Select the following settings: | |
# * "Dropbox API app" | |
# * "Files and datastores" | |
# * "(No) My app needs access to files already on Dropbox" | |
# * "All file types" | |
# * (Choose any app name) |
This file contains 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 editor | |
full_text = editor.get_text() | |
cursor = editor.get_selection()[1] | |
while True: | |
try: | |
if full_text[cursor - 3] + full_text[cursor - 2] + full_text[cursor - 1] == 'def': | |
editor.replace_text(cursor, cursor, ' func_name():') | |
editor.set_selection(cursor + 1, cursor + 10) | |
if full_text[cursor - 3] + full_text[cursor - 2] + full_text[cursor - 1] == 'ifc': | |
editor.replace_text(cursor, cursor, ' condition:') |
This file contains 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
/** | |
* --- Template Meta Program to solve the Partial Knapsack Problem --- | |
* | |
* This little piece of code solves the partial knapsack problem at compile | |
* time. This is not useful in any way. I just wanted to discover the | |
* possibilities of template meta programming. | |
* Note that this code is absolutly awful. First of all: It's a "pure" template | |
* meta program, which is ugly on it's own. Furthermore my code is ugly in | |
* particular. The motivation to clean up super-ugly code to get a little bit | |
* less ugly code is... not that high. |
This file contains 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
/* | |
* Be sure not to close local server at `applicationDidEnterBackground:`. | |
* This causes file not found error in Safari. | |
*/ | |
class LocalHTTPConnection: HTTPConnection { | |
override func httpResponseForMethod(method: String!, URI path: String!) -> NSObject! { | |
if path == LocalWebViewRouter.Profile.URL.path { | |
return LocalProfileReponse(filePath: self.filePathForURI(path), forConnection: self) |
This file contains 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
# coding: utf-8 | |
from objc_util import * | |
import threading | |
NSBundle = ObjCClass('NSBundle') | |
LocalAuthentication = NSBundle.bundleWithPath_('/System/Library/Frameworks/LocalAuthentication.framework') | |
LocalAuthentication.load() | |
LAContext = ObjCClass('LAContext') | |
# authenticate() will raise one of these exceptions when authentication |
This file contains 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 ui | |
import console | |
import keychain | |
import ftplib | |
import os | |
import re | |
import time | |
from datetime import datetime | |
global cur_dir | |
cur_dir = os.path.abspath(os.getcwd()) |
This file contains 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 appex, bs4, dialogs, urllib2, webbrowser | |
if appex.is_running_extension(): | |
starturl = appex.get_url() | |
else: | |
#ask for video url | |
starturl = dialogs.form_dialog(fields=[{'type':'url', 'title':'URL:', 'key':'url'}])['url'] | |
#handle redirects, in case of shortened url | |
url = urllib2.urlopen(urllib2.Request(starturl)).geturl() | |
#keepvid page url | |
url = 'http://www.keepvid.com/?url='+url.split('&feature')[0] |
OlderNewer