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 October 23, 2016 03:42 — forked from pudquick/pipista.py
Version 2.0 of pipista - Unstable branch :)
import os, os.path, sys, urllib2, requests, tempfile, zipfile, shutil, gzip, tarfile
__pypi_base__ = os.path.abspath(os.path.dirname(__file__))
class PyPiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
@sloanlance
sloanlance / pythonista_photos.py
Created October 22, 2016 16:54
Pythonista: test access to iOS photos
import photos
@sloanlance
sloanlance / lazy_apis.md
Created October 21, 2016 20:36
Utilizing assumptions of sloppy APIs to get things done.

Introduction

It's not unusual for web application developers to write UIs that impose some restrictions on the user, but don't employ those same restrictions in the APIs to which those UIs send data. The APIs are written with the assumption the UI has prevented the user from sending invalid input. What happens when those APIs are used with a different UI or no UI at all?

Example

A UI lets the user enter an email address. The UI disallows the user from entering some valid email

# coding: utf-8
# Barcode scanner demo for Pythonista
# Based on http://www.infragistics.com/community/blogs/torrey-betts/archive/2013/10/10/scanning-barcodes-with-ios-7-objective-c.aspx
from objc_util import *
from ctypes import c_void_p
import ui
import sound
found_codes = set()
@sloanlance
sloanlance / GitHub emojicodes
Last active May 25, 2018 20:40
A JSON file of GitHub's emojicodes and emoji. Unlike other projects, this one includes the actual emoji and does not alter GitHub's list. (Short URL: https://goo.gl/S1Xdeu)
A JSON file of GitHub's emojicodes and emoji. Unlike other projects,
this one includes the actual emoji and does not alter GitHub's list.
Also included is a JSON file formatted for use with the Auto Text
Expander extension for Google Chrome, with text to be expanded based
on GitHub's ":EMOJICODE:".
See README.md for details.
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@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
@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 / 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 / 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