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 var _view: UIView? | |
var view: UIView! { | |
get { | |
guard let view = _view else { | |
// force-loading | |
loadView() | |
return _view | |
} | |
} |
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 'package:flutter/widgets.dart'; | |
void main() { | |
runApp(const Center( | |
child: const Text('Hello', textDirection: TextDirection.ltr))); | |
} |
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 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
Widget build(BuildContext context) { | |
return GestureDetector(onTap: () => print('tapped')); | |
} |
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
let arr = ["a", "aa", "aaa", "aaaa", "aaaaa", "aaaaaa"] | |
func getElementCount(_ index: Int) -> Int { | |
guard let value = arr[safe: index] else { return 0 } | |
return value.count | |
} | |
(-5..<10).forEach { | |
print("\($0) : \(getElementCount($0))") | |
} |
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
extension Collection { | |
subscript (safe index: Index) -> Element? { | |
return indices.contains(index) ? self[index] : nil | |
} | |
} |
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
let arr = [1, 2, 3, 4] | |
arr[4] // Fatal error: Index out of range |
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
extension UINavigationController: UINavigationControllerDelegate { | |
open override func viewDidLoad() { | |
super.viewDidLoad() | |
self.delegate = self | |
} | |
public func navigationController( | |
_ navigationController: UINavigationController, | |
didShow viewController: UIViewController, |
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 sumSubarrayMins(A []int) int { | |
dp := make([]int, len(A)+1) | |
stack := []int{-1} | |
res := 0 | |
for i, n := range A { | |
for stack[len(stack)-1] != -1 && n <= A[stack[len(stack)-1]] { | |
stack = stack[:len(stack)-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 | |
import ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"sort" | |
"strconv" | |
"strings" | |
) |
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 | |
import ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"os" | |
"regexp" | |
"strings" | |
) |
NewerOlder