Skip to content

Instantly share code, notes, and snippets.

View sloanlance's full-sized avatar
Certified GitHub Pro

Mr. Lance E Sloan sloanlance

Certified GitHub Pro
View GitHub Profile
@sloanlance
sloanlance / pipista.py
Created June 22, 2016 22:07 — forked from pudquick/pipista.py
pipista - pip module (for installing other modules) for Pythonista
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):
@sloanlance
sloanlance / Appex GetFromURL.py
Created July 11, 2016 01:34 — forked from Dutcho/Appex GetFromURL.py
Appex GetFromURL
# coding: utf-8
# Olaf, Dec 2015, Pythonista 1.6 beta
'''Appex GetFromURL
Pythonista app extension for use on share sheet of other apps to import file from URL into Pythonista
The file is saved at HOME/DESTINATION without user interaction (no 'save as' dialog) unless duplicate'''
from __future__ import print_function
try:
import appex, console, contextlib, itertools, os, os.path, sys, time, urllib, urlparse
@sloanlance
sloanlance / README.md
Last active July 20, 2016 16:20 — forked from lsloan/urltidy.py
Python experiments in removing contiguous slashes from URLs. The `urlparse` module should do this.

This is the README file.

@sloanlance
sloanlance / pip_install.md
Last active August 19, 2016 14:20
Python pip installs
  1. Install package from the source directory:
pip install -e .
  1. Install package from GitHub repo specific branch or tag, with installation config files in a different subdirectory (not the project root):
pip install 'git+_GitHub_repo_URL_@_branch_or_tag_name_#egg=_project_name_&subdirectory=_subdirectory_path_'
@sloanlance
sloanlance / ArcREST_install.md
Created August 19, 2016 14:21
An exceprt of documentation I added to the ArcREST wiki. From: https://github.com/Esri/ArcREST/wiki/1.-ArcREST-Home-page

Since ArcREST's repository directory structure doesn't follow that expected of the usual Python packages (some files that usually appear in the root directory are in the src directory instead), care must be taken to install it using specific commands.

  1. Install from PyPI using pip:

This is recommended in README.md. The package in PyPI is a static build of ArcREST and is not dependent on the contents of the git repository, so the unusual directory structure isn't an impediment.

pip install arcrest_package
@sloanlance
sloanlance / logging_Iso8601UTCTimeFormatter.py
Last active November 25, 2021 03:28
Python: A logging Formatter class giving timestamps in a more common ISO 8601 format.
class Iso8601UTCTimeFormatter(logging.Formatter):
"""
A logging Formatter class giving timestamps in a more common ISO 8601 format.
The default logging.Formatter class **claims** to give timestamps in ISO 8601 format
if it is not initialized with a different timestamp format string. However, its
format, "YYYY-MM-DD hh:mm:ss,sss", is much less common than, "YYYY-MM-DDThh:mm:ss.sss".
That is, the separator between date and time is a space instead of the letter "T"
and the separator for fractional seconds is a comma instead of a period (full stop).
While these differences may not be strictly *wrong*, it makes the formatted timestamp
@sloanlance
sloanlance / macos_vpntoggle.sh
Last active April 13, 2020 20:08
Mac OS X 10.11-ish shell script to toggle VPN connection
#!/bin/sh --
##
## Requires your VPN service to be already configured
## and your password saved in your keychain.
##
## Alter the VPN variable below to contain the name
## of your configured VPN service before running.
##
@sloanlance
sloanlance / svnup.sh
Last active October 5, 2016 18:11
PHP, SVN: Watch a Subversion repo and automatically update the working copy when changes are committed. An old, old hack that fulfilled a need at one time. Clever, but I could do better now. SMDH
#!/bin/sh --
# While working with PHP applications, there were a few obstacles to
# local development. It wasn't possible/easy to get an Oracle server
# or Oracle client for PHP to run under Mac OS X. Furthermore, the
# local environment didn't have the authenticated user's name available
# in the environment. Although an odd situation, it was easier to
# develop on the local machine, commit to SVN, then update a copy of
# the project running on a server that supported Oracle, CoSign, etc.
# The following script, run in the project directory of the server
@sloanlance
sloanlance / restconsole.bash
Created October 6, 2016 20:44 — forked from coderofsalvation/restconsole.bash
restconsole, a simple curl REST api wrapper for bash
#!/bin/bash
# author: Leon van Kammen / Coder of Salvation 2014
#
# restconsole, a simple curl REST api wrapper for bash
rooturl="http://api.yourcompany.com"
apikey="e270f99745341a89e883c583a25b821c"
cache=()
# here you can define your preset calls