Skip to content

Instantly share code, notes, and snippets.

View darhonbek's full-sized avatar

Darkhonbek Mamataliev darhonbek

View GitHub Profile

Dostonbek Oripjonov

Senior Web Developer

GitHub | LinkedIn

Web developer with great potential towards being outstanding candidate in this field. Eager to learn latest technologies and confident about facing new challanges. Continuously work towards being professional.

SKILLS

@darhonbek
darhonbek / resume-dark-mamataliev.md
Last active October 20, 2024 10:14
Resume - Dark Mamataliev

Darkhonbek Mamataliev

Senior iOS Engineer at TikTok · ex Uber

GitHub | LinkedIn | Email

Building pixel perfect apps for 1 billion people. Areas: social network, delivery, finance, logistics.

EXPERIENCE

**TikTok, October, 2023 – Present

@darhonbek
darhonbek / UIImage+SampleBuffer.swift
Created October 11, 2018 15:39
Get UIImage with proper orientation from AVCaptureVideoDataOutputSampleBufferDelegate
func imageFromSampleBuffer(
sampleBuffer: CMSampleBuffer,
videoOrientation: AVCaptureVideoOrientation) -> UIImage? {
if let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) {
let context = CIContext()
var ciImage = CIImage(cvPixelBuffer: imageBuffer)
// FIXME: - change to Switch
if videoOrientation == .landscapeLeft {
ciImage = ciImage.applyingOrientation(3)
@darhonbek
darhonbek / vigenereDecipher.swift
Last active October 5, 2018 15:38
Vigenere's Decipher Tool
import Foundation
// MARK: - Main
var cipherText = "vyc iafgrr xl o ozpghf qw qtvitzrn zorj. rwx qascg mvtvyi bg orgcem vyc gxtnvaibcp fd dnf yvyzgsujch. mvgicuhfg, jcrnfkkw xl bqk yqhiv dyzbbi kcrabqcmvr dgidtvh, dlr btykee rngvfktk inkgbthgcw hthkjdxxr ceb rhbhzbtgh. vyc bxhjfbh mvck uxez ofqi xthvaibjgcw bbbkdgox hjv yqbzkkw dy wpkpjwstj rd vcogpdfwuv gcyctdyibcp jcrnfkkw pks efkeksjvlhbjg lqtk htrgcbbi rls xrwtyibcp. rlnpoa, tmczfcksathkfl, nhi ularxsf km sxqkgftk mqlp ubfuk ktlgcxc xg hjzq rhitjc. xy mql udky jrpsxf vycc rcw ngae pg r edhr eiwemoprjnlh. ccqd, rcw ngae pg r edhr uvajkwvp qexqkrjxlh.".lowercased()
var key = "crypto"
let decipheredText = vigenereDecipher(cipher: cipherText, using: key)
print(decipheredText)
// MARK: - Actions
@darhonbek
darhonbek / FrequencyCounter.swift
Last active October 5, 2018 14:29
Character Frequency Counter
// MARK: - Main
var cipherText = "vyc iafgrr xl o ozpghf qw qtvitzrn zorj. rwx qascg mvtvyi bg orgcem vyc gxtnvaibcp fd dnf yvyzgsujch. mvgicuhfg, jcrnfkkw xl bqk yqhiv dyzbbi kcrabqcmvr dgidtvh, dlr btykee rngvfktk inkgbthgcw hthkjdxxr ceb rhbhzbtgh. vyc bxhjfbh mvck uxez ofqi xthvaibjgcw bbbkdgox hjv yqbzkkw dy wpkpjwstj rd vcogpdfwuv gcyctdyibcp jcrnfkkw pks efkeksjvlhbjg lqtk htrgcbbi rls xrwtyibcp. rlnpoa, tmczfcksathkfl, nhi ularxsf km sxqkgftk mqlp ubfuk ktlgcxc xg hjzq rhitjc. xy mql udky jrpsxf vycc rcw ngae pg r edhr eiwemoprjnlh. ccqd, rcw ngae pg r edhr uvajkwvp qexqkrjxlh.".lowercased()
var frequencyTable = getCharacterFrequency(of: cipherText)
let sortedTable = frequencyTable.sorted(by: {$0.0 < $1.0})
print(sortedTable)
// MARK: - Actions
func getCharacterFrequency(of text: String) -> [Character: Int] {
@darhonbek
darhonbek / CeasarCipher.swift
Last active October 5, 2018 06:46
Ceasar's Cipher Brute Force
// MARK: - Main
var cipherText = "VSRQJHEREVTXDUHSDQWU".lowercased()
let decipheredTexts = decipherText(cipherText)
for (k, s) in decipheredTexts {
print("Shifts: \(k)\t\(s)")
}
// MARK: - Actions
@darhonbek
darhonbek / textField.swift
Created February 17, 2018 10:25
Ensure # of chars dose not exceed the limit (UITextField)
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let nsString = textField.text as NSString?
let newString = nsString?.replacingCharacters(in: range, with: string)
if let string = newString,
string.count > YOUR_LIMIT_HERE {
return false
}
return true
}
@darhonbek
darhonbek / devnotes1.swift
Created January 15, 2018 14:17
DevNotes for iOS beginners: Changing button's label
// Wrong
if bgAudioPlayer.isPlaying {
bgAudioPlayer.stop()
pausePlayButton.titleLabel?.text = "Play"
} else {
bgAudioPlayer.play()
pausePlayButton.titleLabel?.text = "Pause"
}
// Right
@darhonbek
darhonbek / Substring.swift
Created December 25, 2017 11:02
Check if a string contains a substring (Swift 4)
extension String {
func contains(find: String) -> Bool{
return self.range(of: find) != nil
}
func containsIgnoringCase(find: String) -> Bool{
return self.range(of: find, options: .caseInsensitive) != nil
}
}
var value = "Hello world"
@darhonbek
darhonbek / String+Indexation.swift
Last active June 1, 2020 02:16
String Indexation in Swift
extension StringProtocol {
subscript(_ offset: Int) -> Element {
return self[index(startIndex, offsetBy: offset)]
}
subscript(_ range: Range<Int>) -> SubSequence {
return prefix(range.lowerBound+range.count).suffix(range.count)
}