Skip to content

Instantly share code, notes, and snippets.

View MatthiasLamoureux's full-sized avatar

Matthias Lamoureux MatthiasLamoureux

View GitHub Profile
func zalgo(_ string: String, intensity: Int = 5) -> String {
let combiningDiacriticMarks = 0x0300...0x036f
let latinAlphabetUppercase = 0x0041...0x005a
let latinAlphabetLowercase = 0x0061...0x007a
var output: [UnicodeScalar] = []
for scalar in string.unicodeScalars {
output.append(scalar)
guard (latinAlphabetUppercase).contains(numericCast(scalar.value)) ||
(latinAlphabetLowercase).contains(numericCast(scalar.value))
func encode<T>(var value: T) -> NSData {
return withUnsafePointer(&value) { p in
NSData(bytes: p, length: sizeofValue(value))
}
}
func decode<T>(data: NSData) -> T {
let pointer = UnsafeMutablePointer<T>.alloc(sizeof(T.Type))
data.getBytes(pointer)
@cbess
cbess / gist:4444374
Last active March 16, 2020 06:10
Xcode Delete and Duplicate Selected Lines
<key>Customized</key>
<dict>
<key>Delete Line</key>
<string>selectLine:, deleteBackward:</string>
<key>Duplicate Lines</key>
<string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
<key>Duplicate Current Line</key>
<string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
</dict>