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 / Example of GitHub's geoJSON support
Last active December 5, 2016 16:43
geoJSON: An example of a geoJSON file which outlines and labels many countries. It will be rendered with a map viewer in GitHub. Other features, such as cities and regions within countries, may be added by the map viewer. For more info, see: https://help.github.com/articles/mapping-geojson-files-on-github/
Example of GitHub's geoJSON support
@sloanlance
sloanlance / Vim Notebook.md
Last active July 13, 2017 15:42
vim: Notes about using the vim editor, especially useful regular expressions (regex, regexes).

Vim Notebook

Notes about using the vim editor, especially useful regular expressions (regex, regexes).

  • Run an external command on all matching lines

    :g/pattern/.!command

    It's important that the dot command (.) appear between the search pattern and the bang (!) beginning the external command.

@sloanlance
sloanlance / Toggle Hidden Files.scpt
Last active December 3, 2024 11:50
AppleScript: Toggle visibility of hidden files and folders in Finder
-- Place this in ~/Library/Scripts to make it available in the AppleScript menu.
do shell script ¬
(POSIX path of ((path to me as text) & "::")) ¬
& "toggleHiddenFiles.sh"
@sloanlance
sloanlance / Auto Text Expander preferences ℹ️👍😃
Last active January 11, 2017 15:54
Emoji: Emoji and other things that I like Auto Text Expander to fill in for me.
Preferences for Auto Text Expander ℹ️👍😃
@sloanlance
sloanlance / linux_set_time_ntp.md
Created November 10, 2016 20:50
Linux: Set the system time from an NTP server

If ntpdate is installed:

sudo ntpdate pool.ntp.org

To install ntpdate:

sudo apt-get install ntpdate # for Ubuntu-like
@sloanlance
sloanlance / json_tool.py
Created November 2, 2016 18:19
Python: The json.tool included with Python. I copied it to note some changes I'd like to make. From: https://github.com/python/cpython/blob/master/Lib/json/tool.py
r"""Command-line tool to validate and pretty-print JSON
Usage::
$ echo '{"json":"obj"}' | python -m json.tool
{
"json": "obj"
}
$ echo '{ 1.2:3.4}' | python -m json.tool
Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
@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
@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-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 / 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