- 명령 팔레트: cmd+shift+p / ctrl+shift+p
- 현재 파일을 새 창으로 띄우기: cmd + k 후 손가락 떼고 o
- 자동 라인브레이크 토글: option + z
This file contains hidden or 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
| class Singleton private constructor() { | |
| companion object { | |
| // Volatile: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-volatile/index.html | |
| @Volatile private var instance: Singleton? = null | |
| // JvmStatic: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html | |
| @JvmStatic fun getInstance(): Singleton = | |
| instance ?: synchronized(this) { | |
| instance ?: Singleton().also { | |
| instance = it |
This file contains hidden or 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
| ^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$ |
This file contains hidden or 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
| /* | |
| * Copyright (C) 2016 Jeff Gilfelt. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
This file contains hidden or 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
| class Solution { | |
| func arrangeCoins(_ n: Int) -> Int { | |
| let sq = Int(sqrt(Double(n * 2))) | |
| let diff = sq * (sq + 1) / 2 | |
| if n >= diff { | |
| return sq | |
| } else { | |
| return sq - 1 | |
| } | |
| } |
This file contains hidden or 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
| // https://leetcode.com/problems/set-matrix-zeroes/ | |
| class Solution { | |
| func setZeroes(_ matrix: inout [[Int]]) { | |
| if matrix.isEmpty { | |
| return | |
| } | |
| var points = [(Int, Int)]() | |
| let rows = matrix.count | |
| let columns = matrix[0].count |
This file contains hidden or 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
| // Swift 4 | |
| // Check out the history for contributions and acknowledgements. | |
| extension String { | |
| /// Returns a new string made by replacing all HTML character entity references with the corresponding character. | |
| /// decode per unicode because ;️(utf-16 `\u003b\ufe0a`) but i need find ;(utf-8 `\u003b`). | |
| /// - Returns: decoded string | |
| func decodingHTMLEntities() -> String { | |
| let scalars = unicodeScalars |
This file contains hidden or 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 | |
| if [ -f ~/Library/KeyBindings/DefaultkeyBinding.dict ]; then | |
| echo "~/Library/KeyBindings/DefaultkeyBinding.dict already exists" | |
| exit -1 | |
| fi | |
| mkdir -p ~/Library/KeyBindings | |
| cat << EOF > ~/Library/KeyBindings/DefaultkeyBinding.dict | |
| { | |
| "₩" = ("insertText:", "\`"); |
This file contains hidden or 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 quickSort(_ array: [Int]) -> [Int] { | |
| guard array.count > 1 else { return array } | |
| let pivot = array.first! | |
| var left = [Int]() | |
| var right = [Int]() | |
| for i in 1..<array.count { | |
| let value = array[i] | |
| if value < pivot { |
OlderNewer