This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testPasswordCanNotContainUsername() { | |
let (didPass, issue) = OnboardingManager.validatePassword(password: "ValidUsername$123", | |
username: "ValidUsername", | |
email: "valid@example.com", | |
phoneNumber: "+11235554321") | |
XCTAssertFalse(didPass) | |
XCTAssertEqual(issue, PasswordIssue.containsUsername) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect, MutableRefObject } from 'react'; | |
type Location = { x: number; y: number }; | |
type Size = { width: number; height: number }; | |
type Space = { location: Location; size: Size }; | |
// The viewport information for the passed Div. | |
const useViewportSpace = ( | |
scrollArea: MutableRefObject<HTMLDivElement | undefined>, | |
): { content?: Space; viewport?: Space } => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rootPlist=$(plutil -extract dnd_prefs xml1 -o - /Users/"$USER"/Library/Preferences/com.apple.ncprefs.plist) | |
dataPlistB64=$(echo $rootPlist | xmllint --xpath "string(//data)" - ) | |
dataPlist=$(echo $dataPlistB64 | base64 --decode | plutil -convert xml1 - -o -) | |
scheduleDict=$(echo $dataPlist | xmllint --xpath "//dict/key[text()='scheduledTime']/following-sibling::*[1]" -) | |
userPrefDict=$(echo $dataPlist | xmllint --xpath "//dict/key[text()='userPref']/following-sibling::*[1]" -) | |
end=$(echo $scheduleDict | xmllint --xpath "number(//dict/key[text()='end']/following-sibling::*[1])" -) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
This program parses a DOT graph representing a chatbot's state machine. | |
It supports single-select, multiple-select, message-sends, and hooks into programs. | |
*/ | |
import ( | |
"fmt" | |
"gonum.org/v1/gonum/graph" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// `CachedValue` provides a strongly typed interface to UserDefaults. | |
/// It can cache any ``Codable`` type. | |
/// | |
/// Usage: | |
/// 1. Make a struct conforming to `CachedValue` | |
/// * Add a `typealias ValueType = YourType` | |
/// * Optionally add a `static var defaultValue: YourType = YourInstance`. (Your `value` accessor will then be non-optional.) | |
/// * Optionally add a `static var cacheKey: String = "a-very-specific-string-key"`. (By default your key will be your CachedValue conforming type's name.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import QuartzCore | |
import os.log | |
extension OSLog { | |
private static var subsystem = Bundle.main.bundleIdentifier! | |
fileprivate static let osLogCategoryString = "StartupTimerEvents" | |
static let startupTimer = OSLog(subsystem: subsystem, category: osLogCategoryString) | |
} |
OlderNewer