Skip to content

Instantly share code, notes, and snippets.

View rayansostenes's full-sized avatar

Rayan Sóstenes rayansostenes

View GitHub Profile
@rayansostenes
rayansostenes / python_email.py
Created February 12, 2019 14:27
Sending e-mail with python
import smtplib, ssl
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
sender_email = "my@gmail.com"
receiver_email = "your@gmail.com"
password = "your_password"
message = MIMEMultipart("alternative")
message["Subject"] = "multipart test"
FROM ruby:2.5.1
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
# gpg keys listed at https://github.com/nodejs/node#release-team
RUN set -ex \
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
@rayansostenes
rayansostenes / randomLocationInsideCircle.js
Created June 1, 2018 22:47
Random Location Inside Circle
const RADIUS_EARTH = 6378000;
const randomInsideCircle = (center, radius) => {
const { lat, lng } = center;
const [ a, b ] = [ Math.random(), Math.random() ].sort();
const dx = b * radius * Math.cos((2 * Math.PI * a) / b);
const dy = b * radius * Math.sin((2 * Math.PI * a) / b);
#!/usr/bin/env python3
"""
Statement
Given an expression string exp, write a program to examine whether
the pairs and the orders of {,},(,),[,] are correct in exp.
For example:
The program should print True for exp = “[()]{}{[()()]()}” and False for exp = “[(])”
"""
class Triangulo:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def gerar_lados_ordenados(self):
return sorted([self.a, self.b, self.c])
def semelhantes(self, triangulo):
@rayansostenes
rayansostenes / gist:03d1c3aa3a5d2c84df92bdffaf9e7923
Created July 21, 2017 19:23
Find all files that do not contain a pattern
find . -type f | xargs grep -H -c 'id:' | grep 0$ | cut -d':' -f1
(function (doc) {
function getForm() {
return doc.querySelector('#formQuestao');
}
function getQuestionId() {
const form = getForm();
return parseInt(form.querySelector('input[name="questao_id"]').value, 10);
}
# rodrigo.deodoro@esharesinc.com
def validate_matrix(matrix):
# Valida linhas
if not all(list_int(i) for i in matrix):
return False
# Valida colunas
columns = []
import requests
from collections import Counter, defaultdict
class TextSearch:
def __init__(self, url):
self.url = url
self.word_list = [str(v).lower() for v in self.get_text().split()]
self.word_lenght = len(self.word_list)
self.word_count = Counter(self.word_list)
self.count_word = defaultdict(list)
@rayansostenes
rayansostenes / bookmarlet.js
Last active March 21, 2017 00:02
Bookmarlet Nubank to CSV
javascript:window.open('data:text/plain;base64,'+btoa(angular.element(document.querySelector('.md-tab-content:not(.ng-hide) .charge')).scope().$parent.$parent.charges.map(c => `${c.post_date.split('-').reverse().join('/')};${c.title};${c.category};${(c.amount/100).toFixed(2).replace('.', ',')}`).join('\n')))