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
# Xcode | |
DerivedData/ | |
build/ | |
*.pbxuser | |
*.mode1v3 | |
*.mode2v3 | |
*.perspectivev3 | |
!default.mode1v3 | |
!default.perspectivev3 | |
xcuserdata/ |
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 requests | |
from bs4 import BeautifulSoup | |
# URL of the website you want to scrape | |
url = 'https://example.com' | |
# Send an HTTP request to the URL | |
response = requests.get(url) | |
# Check if the request was successful |
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
//Created by SOUR LEANGCHHEAN | |
class PaddedLabel: UILabel { | |
// MARK: - Properties | |
var padding: UIEdgeInsets = .zero { | |
didSet { | |
invalidateIntrinsicContentSize() | |
} |
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 isValidPassword(password: String) -> Bool { | |
// define validation rules here | |
let passwordRegEx = "(?=.*[A-Z])(?=.*[0-9])(?=.*[a-z]).{8,}" | |
let passwordPred = NSPredicate(format: "SELF MATCHES %@", passwordRegEx) | |
return passwordPred.evaluate(with: password) | |
} |
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 isValidEmail(email: String) -> Bool { | |
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}" | |
let emailPred = NSPredicate(format:"SELF MATCHES %@", emailRegEx) | |
return emailPred.evaluate(with: email) | |
} |
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
//Swift 5 | |
//Encoding from image to base64 | |
func convertImageToBase64String (img: UIImage) -> String { | |
return img.jpegData(compressionQuality: 1)?.base64EncodedString() ?? "" | |
} | |
//Decoding from base 64 to image | |
func convertBase64StringToImage (imageBase64String:String) -> UIImage { | |
let imageData = Data(base64Encoded: imageBase64String) |
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
<?php | |
function randomPassword() { | |
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; | |
$pass = array(); | |
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache | |
for ($i = 0; $i < 8; $i++) { | |
$n = rand(0, $alphaLength); | |
$pass[] = $alphabet[$n]; | |
} | |
return implode($pass); //turn the array into a string |
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
//iOS 13, swift 5.1 | |
//Example programmatic constraints with aspect ratio. | |
imageView.translatesAutoresizingMaskIntoConstraints = false | |
//A) 4:3 | |
imageView.heightAnchor.constraint(equalTo: widthAnchor, multiplier: 3.0/4.0).isActive = true | |
//B) 16:9 |
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 | |
extension Data { | |
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription | |
guard let object = try? JSONSerialization.jsonObject(with: self, options: []), | |
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]), | |
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil } | |
return prettyPrintedString | |
} |
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
//Noted: This code is written in Swift 5.1 | |
//By: Sour Leangchhean | |
import LocalAuthentication | |
//Mark: BiometricType for define type | |
enum BiometricType{ | |
case touchID | |
case faceID | |
case none |
NewerOlder