Skip to content

Instantly share code, notes, and snippets.

View math77's full-sized avatar

Matt math77

View GitHub Profile
@math77
math77 / clean_code.md
Created December 6, 2022 15:47 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

location_user = Point(-6.291, -36.020, srid=4326)
Locais.objects.annotate(distance=Distance("location", location_user)).order_by('distance')
@math77
math77 / activity_main.xml
Created May 14, 2019 13:07
Activity com Mapa do Mapbbox
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
@math77
math77 / chatbot.py
Created September 3, 2018 02:09
ChatBot básico feito com Python3 e a biblioteca chatterbot.
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
chatbot = ChatBot("Jarvis")
conversation = [
"Olá",
"Oi, tudo bem?",
"Tudo ótimo, e com vc?",
@math77
math77 / brute_force.py
Created September 1, 2018 19:34
Exemplo de como é fácil descriptografar uma mensagem criptografada com a Cifra de César utilizando butre force
from string import ascii_lowercase as lower
def brutal_force(palavra):
cifras = []
for x in range(0, 26):
cifra = []
for letra in palavra:
cifra.append(lower[(lower.index(letra) - x) % tam])
cifras.append(''.join(cifra))
@math77
math77 / cifra_cesar.py
Created September 1, 2018 18:49
Exemplo de criptografia utilizando a Cifra de César.
from string import ascii_lowercase as lower
tam = len(lower)
def criptografar(palavra, salto):
cifra = []
for letra in palavra:
cifra.append(lower[(lower.index(letra) + salto) % tam])
return ''.join(cifra)