Skip to content

Instantly share code, notes, and snippets.

View rafaeldjsm's full-sized avatar
🎯
Focusing

Rafael de Jesus Silva Monteiro rafaeldjsm

🎯
Focusing
View GitHub Profile
@kennethreitz
kennethreitz / 0_urllib2.py
Created May 16, 2011 00:17
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@brentp
brentp / linear_model.py
Created April 10, 2013 15:57
calculate t statistics and p-values for coefficients in Linear Model in python, using scikit-learn framework.
from sklearn import linear_model
from scipy import stats
import numpy as np
class LinearRegression(linear_model.LinearRegression):
"""
LinearRegression class after sklearn's, but calculate t-statistics
and p-values for model coefficients (betas).
Additional attributes available after .fit()
# Retorna dados sobre o pregão
http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoCarregarDados.asp?CodDado=IBOV,ticker&CA=undefined
# Retorna ações e seus últimos valores negociados
http://www.bmfbovespa.com.br/Pregao-OnLine/ExecutaAcaoCarregarDados.asp?CodDado=Ticker
# Retorna o histórico do dia de um papel
http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoCarregarDadosPapeis.asp?CodDado=petr4
# Retorna dados de um papel
Can anyone convert this algorithm to java implementation?
Python implementation of k prototype
"""
K-prototypes clustering
"""
# Author: 'Nico de Vos' <njdevos@gmail.com>
# License: MIT
@rodrigok
rodrigok / capitais.json
Created May 5, 2016 15:18
TABELA DE DISTÂNCIAS ENTRE AS CAPITAIS BRASILEIRAS EM JSON
[
"Aracajú",
"Belém",
"Belo Horizonte",
"Boa Vista",
"Brasília",
"Campo Grande",
"Cuiabá",
"Curitiba",
"Florianópolis",
# Respondido em: http://pt.stackoverflow.com/questions/184192
tipo_jogo = 0
def computador_escolhe_jogada(n, m):
# Vez do computador:
print("Vez do computador!")
# Pode retirar todas as peças?
@richard512
richard512 / geo-distance-calc.md
Last active November 5, 2021 03:23
Calculate distance between lat long coordinates in excel / libre calc

Using variables

=ACOS(COS(RADIANS(90-Lat1)) *COS(RADIANS(90-Lat2)) +SIN(RADIANS(90-Lat1)) *SIN(RADIANS(90-Lat2)) *COS(RADIANS(Long1-Long2))) *6371

Using Cell References

=ACOS(COS(RADIANS(90-A2)) *COS(RADIANS(90-A3)) +SIN(RADIANS(90-A2)) *SIN(RADIANS(90-A3)) *COS(RADIANS(B2-B3))) *6371

That'll work for a table set up like this:

Name Lat Long
@pierdom
pierdom / distr_fitting.ipynb
Last active January 19, 2022 10:30
[Find best fitting distributions] Find the best fitting PDFs (power distribution functions) from a list of well-known distributions in scipy. Inspired by this: https://stackoverflow.com/questions/6620471/fitting-empirical-distribution-to-theoretical-ones-with-scipy-python #datascience #python #matplotlib #visualization #statistics
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@enzoftware
enzoftware / sobel-filter.py
Last active October 5, 2021 19:03
Sobel filter in Python for edge detection 🐍
from PIL import Image
import math
path = "peru.jpeg" # Your image path
img = Image.open(path)
newimg = Image.new("RGB", (width, height), "white")
for x in range(1, width-1): # ignore the edge pixels for simplicity (1 to width-1)
for y in range(1, height-1): # ignore edge pixels for simplicity (1 to height-1)
# initialise Gx to 0 and Gy to 0 for every pixel
Gx = 0
########################################## Importing Data in Python (Part 2) #############################################
########################################## Importing flat files from the web: your turn! #################################
# You are about to import your first file from the web! The flat file you will import will be 'winequality-red.csv' from the University # of California, Irvine's Machine Learning repository. The flat file contains tabular data of physiochemical properties of red wine,
# such as pH, alcohol content and citric acid content, along with wine quality rating.
# The URL of the file is