Skip to content

Instantly share code, notes, and snippets.

@bennr01
bennr01 / crossopen.py
Last active April 2, 2019 13:50
Use the Pythonista App to open an URL on your PC
"""
Open an URL on pc.
You need to configure pythonista to run this script when "open in" is used.
Replace YOUR_HOST_OR_IP with your ip or hostname.
"""
#!python2
import socket
import appex
HOST = "YOUR_HOST_OR_IP" # host/IP to connect to
@bennr01
bennr01 / host_is_local.py
Created July 11, 2017 13:49
python: check wether a hostname/IP refers to the localhost
"""
check if an ip address or hostname is local.
NOTE: IPv6 support is NOT 100% tested. Some IPv6 addresses seem to work, others not.
"""
import socket
def host_is_local(hostname, port=None):
"""returns True if the hostname points to the localhost, otherwise False."""
if port is None:
@bennr01
bennr01 / stash_cmd2url.py
Last active December 14, 2016 14:01
Converts a StaSh (see https://github.com/ywangd/stash/) command to an URL executing the command using the pythonista URL scheme.
#!python2
"""encodes a StaSh command to a pythonista3 URL-scheme."""
# If you dont know what StaSh is, check it out:
# https://www.github.com/ywangd/stash/
# This script requires a feature which will soon be included in a pull-request
# (and hopefully be accepted)
import urllib
import clipboard