Skip to content

Instantly share code, notes, and snippets.

View diogojorgebasso's full-sized avatar
🥉
Studying at UNIFEI

Diogo Basso diogojorgebasso

🥉
Studying at UNIFEI
View GitHub Profile
@diogojorgebasso
diogojorgebasso / settings.json
Created December 14, 2020 20:39
My Config in Visual Studio Code
{
"terminal.integrated.fontSize": 15,
"workbench.iconTheme": "material-icon-theme",
"workbench.startupEditor": "newUntitledFile",
"editor.tabSize": 2,
"editor.fontSize": 16,
"editor.lineHeight": 22,
"editor.fontFamily": "Fira Code",
@diogojorgebasso
diogojorgebasso / outer_function.py3
Created December 25, 2020 13:38
This is beautiful!!
def will_print(message):
"Outer Function"
def will_question():
"Nested Function"
print(message)
will_question() #yes!
will_print("Some random message")
@diogojorgebasso
diogojorgebasso / fizz_buzz_decorators.py3
Created December 25, 2020 14:03
Let's create the HackerRank example "FizzBuzz" with decorators in Python!
def fizz_buzz_generator(function):
def wrapper(): #standar name
func = function()
lista =[]
for x in range(1,func+1):
if x%3==0 and x%5==0 :
lista.append("FizzBuzz")
elif x%5==0:
lista.append("Buzz")
elif x%3==0:
@diogojorgebasso
diogojorgebasso / convertingunits.js
Created January 3, 2021 01:49
Converting decimal to binary in JS and vice-versa
let decimalToBinary = (dec=0) => (dec >> 0).toString(2)
let binaryToDecimal = (bin) => parseInt(bin, 2).toString(10)
let isoCountries = {
AF: "Afghanistan",
AX: "Aland Islands",
AL: "Albania",
DZ: "Algeria",
AS: "American Samoa",
AD: "Andorra",
AO: "Angola",
AI: "Anguilla",
AQ: "Antarctica",
@diogojorgebasso
diogojorgebasso / functionComposition.js
Created January 12, 2021 21:27
How to create composition for N functions in Javascript
function composition(...functions){
return function(value){
return functions.reduce((acc, fn) =>fn(acc), value)
}
}//very flexible
function scream(text){
return text.toUpperCase()
}
@diogojorgebasso
diogojorgebasso / fibbonacci.js
Created January 17, 2021 02:03
Doing the same Fibonacci operation, with very different performance
//easy to visualize and code, but...
function fib(n) {
if (n <= 1) return 1;
return fib(n - 1) + fib(n - 2);
}
//very time-consuming.
//SOLUTION
//using memoization
function fib(n) {
@diogojorgebasso
diogojorgebasso / make_request.html
Created January 27, 2021 23:46
An HTML template for making a simple request http in Github's API
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
let xhr = new XMLHttpRequest
xhr.open('GET', 'https://api.github.com/users/DiogoJBasso')
xhr.send(null)
@diogojorgebasso
diogojorgebasso / rocketseat_gabarito.js
Created January 27, 2021 23:49
Gabarito de Desafios em JS pela Rocketseat!!
//DISCLAIMER: Esses desafios podem ser encontrados na página da RocketSeat
/*Enunciado:
Crie uma função que dado o objeto a seguir:
var endereco = {
rua: "Rua dos pinheiros",
numero: 1293,
bairro: "Centro",
cidade: "São Paulo",
uf: "SP"
};
@diogojorgebasso
diogojorgebasso / Reading_csv.py
Created January 28, 2021 00:40
This Python Gist shows how to read and log a CSV with pandas.
import pandas as pd
df = pd.read_csv("https://pycourse.s3.amazonaws.com/bike-sharing.csv")
df.head()