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
function calculateFizzBuzz(num) { | |
for ( var i = 0; i < num.length; i++) { | |
if (i % 15 == 0) { | |
console.log(i + " FizzBuzz"); | |
} else if (i % 3 == 0) { | |
console.log(i + " Fizz"); | |
} else if (i % 5 == 0) { | |
console.log(i + " Buzz"); | |
} | |
} |
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
function isPangramma(string) { | |
/** | |
define constant that hold alphabet count. We take in considiration that the alphabet is 'english'.8 | |
*/ | |
const alphabetCount = 26; | |
/** | |
Create new string that trims whitespaces from passed to function string as a parameter | |
*/ |
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
/** | |
Palindrome algorithm. | |
Palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, | |
such as 'madam' or 'racecar'. | |
*/ | |
function isPalindrome(string) { | |
/** | |
initialize variable that holds reversed passed string and make this string lowercese | |
*/ |
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
/** | |
Convert nested array to flat array | |
*/ | |
function flattenArray(arr) { | |
/** | |
Create en empty array. In this array we will push elements from nested array passed | |
as a parameter. | |
*/ | |
var flatArray = []; |
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
/** | |
Binary search algorithm | |
*/ | |
// ------------------------------------------------------------------------------------------------- | |
/** | |
Helper function that generates array of numbers from 0 to (n) elements | |
*/ |
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
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
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 bcf = ByteCountFormatter() | |
bcf.allowedUnits = [.useMB] // optional: restricts the units to MB only | |
bcf.countStyle = .file | |
let string = bcf.string(fromByteCount: Int64(data.count)) | |
print("formatted result: \(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
func textField(textField: UITextField!, shouldChangeCharactersInRange range: NSRange, replacementString string: String!) -> Bool { | |
if let text = textField.text as NSString? { | |
let txtAfterUpdate = text.replacingCharacters(in: range, with: string) | |
self.callMyMethod(txtAfterUpdate) | |
} | |
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
private func setupFormValidator() { | |
formValidator.rules.minValue = 1 | |
formValidator.rules.maxValue = 2000 | |
formValidator.addValidationTo( | |
view: receiverTextField, type: .require, fieldType: .none, errorMessage: "EmptyFormFieldError".localized, | |
errorMessageTitle: formTitleLabel.text) | |
if transferType == .receive || transferType == .refund { | |
formValidator.addValidationTo( |
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
[alias] | |
parent = "!git show-branch | grep '*' | grep -v \"$(git rev-parse --abbrev-ref HEAD)\" | head -n1 | sed 's/.*\\[\\(.*\\)\\].*/\\1/' | sed 's/[\\^~].*//' #" |
OlderNewer