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
# In this gist, I want to share 2 concepts: | |
# 1. Use startswith (similar with endswith) method. | |
# 2. Use single conditions instead of multiple conditions. | |
names = ["Wilmer", "Elong", "Linus", "Cristiano" ] | |
# classic use with or condition | |
for name in names: | |
if name.startswith("W") or name.startswith("Cr"): |
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
// Función que se ejecuta inmediatamente y retorna la suma de un binomio con exponente c | |
(function(a,b,c){ | |
console.log((a+b)**c) | |
})(3,2,2) | |
// Example (3+2)**2 =25 |
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 operacionescon(number){ | |
let first_number = number | |
return { | |
suma: function (other_number){ | |
return first_number + other_number | |
}, | |
resta:function(other_number){ | |
return first_number - other_number | |
}, |
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
{ | |
"parserOptions": { | |
"ecmaVersion": 2018 | |
}, | |
"extends": [ | |
"eslint:recommended", | |
"prettier" | |
], | |
"env": { | |
"es6": 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
def controller_time(func): | |
def wrapper(*args, **kwargs): | |
initial_time = time.time() | |
func(*args,**kwargs) | |
final_time = time.time() | |
seconds = final_time - initial_time | |
print(f'The function {func.__name__} took {seconds} seconds') | |
return wrapper |
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
#unclean | |
phrase= " h e l l o " | |
#remove external spaces | |
phrase= phrase.strip() | |
#remove all spaces | |
phrase= phrase.replace(" ", "") |