Skip to content

Instantly share code, notes, and snippets.

View joopeed's full-sized avatar
:shipit:
shipping code around

João Pedro Leôncio joopeed

:shipit:
shipping code around
View GitHub Profile
@joopeed
joopeed /
Created August 25, 2019 22:24
@joopeed
joopeed / clean_code.md
Last active September 13, 2018 01:20 — 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

@joopeed
joopeed / Classificador.py
Created September 10, 2014 02:29
Classificando as noticias
#coding:utf-8
import csv
import nltk.classify.util
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import stopwords
stopset = set(stopwords.words('english'))
data_pos = []
data_neg = []
@joopeed
joopeed / analisador.py
Last active August 29, 2015 14:05
Fetch and analyze news results
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.cluster import KMeans, MiniBatchKMeans, DBSCAN
from scipy.spatial.distance import cdist, pdist
import numpy as np
import json, nltk
stop_words = [] #nltk.corpus.stopwords.words('portuguese')
dados = json.loads(open("validos.json", "r").read())
vectorizer = TfidfVectorizer(max_df=0.5,
@joopeed
joopeed / fetch_news.py
Last active August 29, 2015 14:05
Fetching and saving news for a list of Companies
#coding:utf-8
from bs4 import BeautifulSoup
import urllib2, sys, subprocess
from time import sleep
import codecs
from goose import Goose
g = Goose()
def fetch_news(term):
results = []
@joopeed
joopeed / groupData.R
Created August 5, 2014 18:55
groupData.R
bestdados <- c()
for(i in 1:9) {
# funcao para melhorar a forma dos dados
temp <- c()
cols <- grep(toString(i), colnames(dados))
temp <- dados[c(1, 2, 3, 4, 5, 6, cols)]
temp$ano <- toString(i)
names(temp) <- gsub(toString(i), "", names(temp))
bestdados <- rbind(bestdados, temp)
}
ci_by_group <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE,
conf.interval=.95, .drop=TRUE) {
require(plyr)
#Usando a funcao de raquel e adaptando
ci = function(x, alpha = 0.01) {
q = 1 - alpha/2
s = sd(x)
xbar = mean(x)
n = length(x)
ci_by_group <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE, .drop=TRUE) {
require(plyr)
#Usando a funcao de raquel
ci = function(x, alpha = 0.01) {
q = 1 - alpha/2
s = sd(x)
xbar = mean(x)
n = length(x)
error = qnorm(q)*s/sqrt(n)
package sorting.simpleSorting;
import sorting.SortingImpl;
import sorting.Util;
/**
* The selection sort algorithm chooses the smallest (greatest) element form the
* array and puts it in the first (last) position. Then it repeats the same
* process to put the second smallest (greatest) element in the second (second
* from the end) position, and so on. The algorithm must sort the elements from
package com.portaslogicas;
public class PortasLogicas {
public int AND(int A, int B){
if(A > B) return B;
if(B > A) return A;
return A;
}