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 / disable_macOS_parental_controls.sh
Last active September 7, 2021 16:00
Disable Parental Controls and other services in macOS Sierra (OS X)
#!/bin/bash
# This is a draft but it works
# FIRST (I don't even know if it works but we'll assume yes)
# sudo launchctl list
# sudo launchctl disable system/netbiosd
# sudo launchctl disable system/parsecd
# sudo launchctl disable system/parentalcontrols.check
# sudo launchctl disable system/airportd
@sloanlance
sloanlance / total.sh
Last active January 10, 2017 21:31
BASH: Total a list of numbers
#!/bin/sh --
# Read numbers from stdin, one per line,
# concatenate them with the addition operator between them,
# and add them together with bc
paste -sd+ - | bc
Gist title: XSLT for JSON
Summary: In response to a Stack Overflow question about an XSLT equivalent for processing JSON,
I posted an answer (http://stackoverflow.com/a/34910682/543738) suggesting DefiantJS. Also, a
JSFiddle version (https://jsfiddle.net/lsloan/8dt9egjf/).
@sloanlance
sloanlance / Adblock Plus: Anti-anti-adblock rules for forbes.com
Last active June 6, 2018 04:37
Prevent forbes.com from displaying "disable your adblocker" messages. Use Adblock Plus and add a subscription to this gist as: https://gist.githubusercontent.com/sloanlance/11cea790e4cbb8e644e0b9d86e661992/raw/forbes_com-anti_adblock.txt
Gist title: Adblock Plus: Anti-anti-adblock rules for forbes.com
#!/bin/sh --
# The macOS "defaults domains" command writes a comma-delimited list of domains to stdout.
# I wanted to get the domains as a list, one per line, without commas.
# Inspired by:
# http://stackoverflow.com/questions/723157/how-to-insert-a-newline-in-front-of-a-pattern
# http://stackoverflow.com/questions/17363030/how-do-i-insert-a-newline-linebreak-after-a-line-using-sed
# Default output
@sloanlance
sloanlance / macOS menubar clock.sh
Last active December 18, 2016 02:14
Read the menubar clock properties, and change them.
defaults read com.apple.menuextra.clock
#{
# DateFormat = "EEE HH:mm";
# FlashDateSeparators = 0;
# IsAnalog = 0;
#}
defaults write com.apple.menuextra.clock DateFormat 'EEE HH:mm:ss'
killall SystemUIServer

Valid Email Addresses

Many websites attempt to validate email addresses based on formatting rules alone. Often, they use regular expressions which may turn out to be wrong, which is difficult to notice due to their complexity. Attempting to do very much validation of email addresses is usually a mistake and should be avoided.

The most common problem I've seen personally, from the perspective of a website user, is that email addresses containing a plus-sign (+) are considered invalid. For example, an email address like [email protected] is often rejected as invalid. However, that conclusion is incorrect.

  • According to RFC 3696 from the IETF, + is a valid character for the "local part" (the part before the @ sign).
  • According to RFC 5233, the [email protected] address is valid and the receiving mail server will deliver messages for that address to the user with the address
@sloanlance
sloanlance / BASH: ISO 8601 Timestamp with Milliseconds
Last active May 6, 2024 14:40
How to get an ISO 8601 timestamp with milliseconds in BASH
Gist title: "BASH: ISO 8601 Timestamp with Milliseconds"
Summary: How to get an ISO 8601 timestamp with milliseconds in BASH
#!/usr/bin/python
# -*- coding: utf-8 -*-
# From http://nedbatchelder.com/blog/200712/human_sorting.html
import re
def tryint(s):
try:
return int(s)
@sloanlance
sloanlance / JSONView-for-Chrome security vulnerability
Last active December 5, 2016 23:12
JSONView-for-Chrome/pull/76
JSONView-for-Chrome security vulnerability