Skip to content

Instantly share code, notes, and snippets.

View ricardovsilva's full-sized avatar

Ricardo da Verdade Silva ricardovsilva

View GitHub Profile
@ricardovsilva
ricardovsilva / index.js
Last active May 23, 2021 23:00
example of async/await js
/* Todas as funções async do js retornam sempre Promises. As Promises podem retornar algo
* ou não. Se você retornar uma string em um método async, será retornada uma Promise que
* resolve em uma string.
*/
/* Só é possível usar a palavra await dentro de funções assincronas. */
const axios = require('axios');
const api = 'https://swapi.dev/api/';
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D

Basic Git Commands For Rookies

Comando Descrição
git clone https://myrepositoryurl.com Copia o repositório inteiro para o seu PC
git add . Marca todos os arquivos para serem comitados, este comando não comita os arquivos.
git commit -m "My message here" Comita todos os arquivos adicionados pelo comando git add
git push Envia todos os commits criados para o server
git pull Atualiza o seu repositório de acordo com o repositório do server
git status Mostra todos os arquivos que foram adicionados ou alterados

If you want to debug HTTPS requests, you must execute, at any point of your code, these command:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

Then, you must add the following lines to your web.config:

<system.net>
	<defaultProxy enabled="true">
		<proxy proxyaddress="http://127.0.0.1:8888" bypassonlocal="False"/>
@ricardovsilva
ricardovsilva / code_skulptor_timer_example.py
Last active February 3, 2016 13:25
Example of code skulptor exercise that use timer
import simplegui
time = 0
points = 0
def format(time):
A = time // 600
B = time // 60
C = time % 60
@ricardovsilva
ricardovsilva / python-list.py
Created February 2, 2016 13:59
My solution for python-list exercise of hackerrank.com
quantity_commands = int(raw_input())
lines = []
for i in range(0, quantity_commands):
input = raw_input()
lines.append(input)
L = []
for line in lines:
parameters = str.split(line)
@ricardovsilva
ricardovsilva / list.py
Created February 2, 2016 12:34
Example of list usage in python
n = int(raw_input())
my_new_list = []
while n >= 0:
my_new_list.insert(0, 5)
my_new_list.insert(1, 10)
my_new_list.insert(0, 6)
print my_new_list
my_new_list.remove(6)
my_new_list.append(9)
@ricardovsilva
ricardovsilva / calculate_average.py
Created February 1, 2016 16:26
Example to calculate average from list in python
def calculate_average(verifide_notes):
float_list = map(float, verifide_notes)
average = sum(float_list)/float(len(float_list))
return average
n = int(raw_input())
students_data = {}
for i in range(0,n):
#transforms each item of input in a string that contain de name of a student and their notes
aux = str.split(raw_input())
#remove the first item of a list which is the name of a studant
student_name = aux.pop(0)
#take the notes of a studant
@ricardovsilva
ricardovsilva / map_example.py
Created February 1, 2016 15:19
Example of use of map function. This is usefull to convert a list of some type to other.
string_list = ["92", "27", "45", "23"]
print string_list
#["92", "27", "45", "23"]
print string_list[0] + string_list[1]
#9227
integer_list = map(int, string_list)
print integer_list