Skip to content

Instantly share code, notes, and snippets.

View thatswiftguy's full-sized avatar
🎯
Focusing

Yasir thatswiftguy

🎯
Focusing
View GitHub Profile
// Mark:- First Point
private func addingOf(_ num1: Int, and num2: Int) {
print("\(num1) + \(num2) = \(num1 + num2)")
}
// Mark:- Second Point
private func increment(_ value: inout Int) {
value += 1
print(value)
}
@thatswiftguy
thatswiftguy / readme.md
Created June 17, 2021 11:41 — forked from benstr/readme.md
Gist Markdown Cheatsheet

#Heading 1 ##Heading 2 ###Heading 3 ####Heading 4 #####Heading 5 ######Heading 6


Paragraph

let pass = NSPredicate(format: "SELF MATCHES %@ ", "^(?=.*[a-z])(?=.*[$@$#!%*?&])(?=.*[A-Z]).{6,}$")
pass.evaluate(with: "SomStrin&&") // true
pass.evaluate(with: "nononnsdf") // false
func isValidEmail(_ email: String) -> Bool {
let emailCode = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let emailPredicate = NSPredicate(format:"SELF MATCHES %@", emailCode)
return emailPredicate.evaluate(with: email)
}
var todaysTimeStamp = 1621429320
var today : Date = Date(timeIntervalSince1970: todaysTimeStamp )
let now = Date()
let olderDate = Date(timeIntervalSinceNow: -10000)
var order = Calendar.current.compare(now, to: olderDate, toGranularity: .day)
switch order {
case .orderedDescending:
print("DESCENDING")
case .orderedAscending:
func singUp(){
Auth.auth().createUser(withEmail: email, password: password) { (result, error) in
guard error == nil else {
print(error!.localizedDescription)
return
}
print("WE have Signed Up")
}
}
import Foundation
class WeatherManager : ObservableObject {
@Published var tempText : Double = 0.0
@Published var conditionImage : Int = 0
@Published var cityName = ""
let weatherURL = "https://api.openweathermap.org/data/2.5/weather?appid={YOUR API KEY}&units=metric"
struct WeatherData : Codable {
let name : String
let main : Main
let weather : [Weather]
}
struct Main : Codable {
let temp : Double
}
@thatswiftguy
thatswiftguy / quicksort.swift
Created April 27, 2021 15:12
Quick Sort Algorithm
var myarray4 = [4,6,2,7,7,3,5]
func quickSort(array: inout [Int], startIndex: Int, endIndex: Int) {
if startIndex >= endIndex {
return
}
let pivot = partition(array: &array, startIndex: startIndex, endIndex: endIndex)
quickSort(array: &array, startIndex: startIndex, endIndex: pivot-1)
quickSort(array: &array, startIndex: pivot+1, endIndex: endIndex)