Skip to content

Instantly share code, notes, and snippets.

@tbveralrud
tbveralrud / escapeImplicitAutofillValue.ts
Last active Mar 27, 2019
How to escape implicit autofill values in HTML label elements
View escapeImplicitAutofillValue.ts
// Browsers don't respect `autocomplete='off'`.
// Safari (maybe others) will inspect the text value of a `label` element to predict intent.
// Sometimes we want to include 'name' in the value and not have it interpreted as a 'user name'.
// This function will transform the string to a visually equivalent string by inserting `zero width join` characters.
const wordJoiner = '\u{2060}';
export function escapeImplicitAutofillValue(label: string): string {
return label.split('').join(wordJoiner);
}
@tbveralrud
tbveralrud / CustomLuaBinding.swift
Created Jan 25, 2018
lua4swift: General type checker for custom Lua Userdata types
View CustomLuaBinding.swift
import Lua
protocol CustomLuaBinding: CustomTypeInstance {
/// This is a 'type checker' function.
/// It is used to validate expected types when binding a method to a Lua-wrapped type.
///
/// e.g.
/// ```
/// type.createMethod([Foo.arg, Bar.arg, Baz.arg], _ fn: ....)
@tbveralrud
tbveralrud / submodule-update-fix-snippet.yml
Created Jan 21, 2016
(Temporary) Fix for submodule update error on CircleCI
View submodule-update-fix-snippet.yml
# CircleCI failed to build a git submodule update step.
# Tracked it down to partially complete .git/modules existing in our source cache.
# This removes the .git/modules directory before the submodule update.
# The error:
# $ git submodule update --init
# git submodule update --init returned exit code 128
# fatal: Not a git repository: ../.git/modules/<project> Action failed: git submodule update --init
checkout: