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 / 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)
# 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 / 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
@iamlemec
iamlemec / vector.css
Created August 3, 2016 20:09
Wikipedia CSS (for vector theme) that makes things look super modern and awesome.
@import url(//fonts.googleapis.com/css?family=Open+Sans:400,700,400italic,700italic);
body {
background-color: white;
font-family: 'Open Sans', sans-serif;
}
#content {
width: 700px;
margin-top: 50px;
@lsloan
lsloan / stringContainsCharacters.py
Created July 26, 2016 20:22
Python: A couple of methods to check whether a string contains any or all of the characters from a second string.
def stringContainsAnyCharacters(string, characters):
"""
Check whether 'string' contains any characters from string 'characters'.
:param string: String to check for wanted characters
:type string: str
:param characters: String of characters to be found
:type characters: str
:return: True if any characters are found, False otherwise
:rtype: bool