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.
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 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) |
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 | |
// 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 |
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
// 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] { |
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
// MARK: - Main | |
var cipherText = "VSRQJHEREVTXDUHSDQWU".lowercased() | |
let decipheredTexts = decipherText(cipherText) | |
for (k, s) in decipheredTexts { | |
print("Shifts: \(k)\t\(s)") | |
} | |
// MARK: - Actions |
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 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 | |
} |
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
// Wrong | |
if bgAudioPlayer.isPlaying { | |
bgAudioPlayer.stop() | |
pausePlayButton.titleLabel?.text = "Play" | |
} else { | |
bgAudioPlayer.play() | |
pausePlayButton.titleLabel?.text = "Pause" | |
} | |
// Right |
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 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" |
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 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) | |
} | |
NewerOlder