Skip to content

Instantly share code, notes, and snippets.

@adam-zethraeus
adam-zethraeus / copy_url_to_selection_bookmarklet.js
Last active Sep 10, 2020
a bookmarklet to copy a url to the current page, with the current selection highlighted. (Chrome only. Because other browser care about timing attacks more than your Google search result experience.)
View copy_url_to_selection_bookmarklet.js
javascript:
let tempInput = document.createElement("input");
tempInput.value = window.location.href + `#:~:text=${window.getSelection().toString()}`;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
View BetterOnboardingManagerTestsExcerpt.swift
func testPasswordCanNotContainUsername() {
let (didPass, issue) = OnboardingManager.validatePassword(password: "ValidUsername$123",
username: "ValidUsername",
email: "valid@example.com",
phoneNumber: "+11235554321")
XCTAssertFalse(didPass)
XCTAssertEqual(issue, PasswordIssue.containsUsername)
}
View BadOnboardingManagerTestExcerpt.swift
func test_PasswordCanNotContainUsername() {
let mockPasswordCollectorLauncher = MockPasswordCollectorLauncher()
let mockListener = MockOnboardingManagerListener()
let onboardingManager = BadOnboardingManager(passwordCollectorLauncher: mockPasswordCollectorLauncher)
onboardingManager.listener = mockListener
onboardingManager.start()
// TODO: assert the username collector launches now.
onboardingManager.usernameCollectorReturned(username: "ValidUsername")
View BadOnboardingManagerExcerpt.swift
private func validatePassword() {
self.passwordIsValid = false
self.passwordIssue = nil
guard let username = self.username,
let email = self.email,
let phoneNumber = self.phoneNumber,
let password = self.password
else {
return
@adam-zethraeus
adam-zethraeus / gist:4583560
Created Jan 21, 2013
Stick it in your .bash_profile on your mac to get QuickLook from the terminal.
View gist:4583560
alias ql='qlmanage -p "$@" > /dev/null'
You can’t perform that action at this time.