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 / 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.
# 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 / 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

@sloanlance
sloanlance / pythonista_photos.py
Created October 22, 2016 16:54
Pythonista: test access to iOS photos
import photos
@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 / pip-mini.py
Created October 23, 2016 03:44 — forked from pudquick/pip-mini.py
Minimal version of pip in a standalone form for handling pure python situations (Pythonista, etc.)
# Standalone mini version of pip
# Geared towards Pythonista, but easily adaptable to other pure python installs
import argparse, copy, gzip, os, os.path, re, requests, shutil, site, sys, tarfile, time, xmlrpclib
# Where packages will end up installed
site_packages = site.USER_SITE
# Root of Pythonista saveable document location
pythonista_base = os.path.split(site_packages)[0]
# Temporary directory for work
@sloanlance
sloanlance / git-temporary-ignore.md
Last active March 19, 2025 23:27
git: A couple ways to temporarily ignore changed or new files without altering .gitignore.

There are times notifications aren't wanted about either a changed repo file or a new file that needs to be added to the repo. However, adding the name of the file to .gitignore might not be a good option, either. For example, locally-generated files that other users aren't likely to generate (e.g., files created by an editor) or files of experimental test code might not be appropriate to appear in a .gitignore file.

In those cases, use one of these solutions:

  1. If the file is a changed repo file

    Use the command:

    git update-index --assume-unchanged "$FILE"

@sloanlance
sloanlance / app-status.sh
Last active October 28, 2016 18:11
BASH: Script to determine whether an application is running.
#!/bin/bash --
# File containing the process ID of the application, written by the application
PID_FILE='app.pid'
# The process name or some string unique to the application's process
PROCESS_NAME="java -Dspring.config.location=${HOME}/application.properties"
[[ $# -gt 0 && $1 = '-v' ]] && VERBOSE=1
@sloanlance
sloanlance / git-exclude.sh
Last active October 28, 2016 19:53
git: A git extension to add a filename to the local repository's `exclude` file.
#!/bin/sh --
# Save as "git-exclude" and set the executable flag.
# Execute as "git exclude repo_path file_path"
if [ $# -ne 2 ]; then
echo "usage: $(basename $0 | sed 's/-/ /g') <repo-dir> <file-path>" > /dev/stderr
exit $(false)
fi