<commit_before>from joblib import Parallel, delayed  
import multiprocessing
import psycopg2
import sys
import numpy as np
import scipy.stats  # Para o kernel density estimation
import cgi, cgitb
import hashlib
import redis
cgitb.enable()  # debug

data = cgi.FieldStorage()

latitude = []
longitude = []
estado = []

try:
    dataFromPHP = sys.argv[1]
except:
    print "ERROR"
    sys.exit(1)

#verifica se essa consulta ja esta em cache
redis = redis.Redis('localhost')
chave = '3'#hashlib.md5(dataFromPHP).hexdigest()
if(redis.get(chave) == ''):
	print redis.get(chave)
else:
	#substitua com os dados do seu banco
	try:
		conn = psycopg2.connect("host='localhost' dbname='banco' user='usuario' password='<PASSWORD>'")
	except:
		print "Nao conectou!"

	#database operations
	cur = conn.cursor()

	cur.execute(dataFromPHP)
	linhas = cur.fetchall()

	cur.close()
	conn.close()

	def pegaLatLonUF(linhas):
		for linha in linhas:
			latitude.append( float(linha[0]) )<commit_msg>Update kde.py<commit_after>from joblib import Parallel, delayed  
import multiprocessing
import psycopg2
import sys
import numpy as np
import scipy.stats  # Para o kernel density estimation
import cgi, cgitb
import hashlib
import redis
cgitb.enable()  # debug

data = cgi.FieldStorage()

latitude = []
longitude = []
estado = []

try:
    dataFromPHP = sys.argv[1]
except:
    print "ERROR"
    sys.exit(1)

#verifica se essa consulta ja esta em cache
redis = redis.Redis('localhost')
chave = hashlib.md5(dataFromPHP).hexdigest()
if(redis.get(chave)):
	print redis.get(chave)
else:
	#substitua com os dados do seu banco
	try:
		conn = psycopg2.connect("host='localhost' dbname='banco' user='usuario' password='<PASSWORD>'")
	except:
		print "Nao conectou!"

	#database operations
	cur = conn.cursor()

	cur.execute(dataFromPHP)
	linhas = cur.fetchall()

	cur.close()
	conn.close()

	def pegaLatLonUF(linhas):
		for linha in linhas:
			latitude.append( float(linha[0]) )
{'fraction_non_alphanumeric': 0.12114989733059549, 'fraction_numerical': 0.006673511293634497, 'mean_word_length': 4.682215743440233, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6908579', 'n_tokens_mistral': 738, 'n_tokens_neox': 716, 'n_words': 187}