This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dados_do_local(endereco): | |
""" | |
Dado o endereco, retorna o endereco processado, a latitude e a longitude do local. | |
Exemplo: | |
place, (lat, lng) = dados_do_local(endereco) | |
""" | |
from geopy import geocoders | |
if hasattr(settings, "EASY_MAPS_GOOGLE_KEY") and settings.EASY_MAPS_GOOGLE_KEY: | |
g = geocoders.Google(settings.EASY_MAPS_GOOGLE_KEY) | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Exemplo de formatação de datas no Sql Server | |
SELECT | |
CONVERT(VARCHAR(12),GETDATE(),101) AS '101', --mm/dd/aaaa | |
CONVERT(VARCHAR(12),GETDATE(),102) AS '102', --aa.mm.dd | |
CONVERT(VARCHAR(12),GETDATE(),103) AS '103', --dd/mm/aaaa | |
CONVERT(VARCHAR(12),GETDATE(),104) AS '104', --dd.mm.aa | |
CONVERT(VARCHAR(12),GETDATE(),105) AS '105', --dd-mm-aa | |
CONVERT(VARCHAR(12),GETDATE(),106) AS '106', --dd mês aa | |
CONVERT(VARCHAR(12),GETDATE(),107) AS '107', --Mês dd, aa | |
CONVERT(VARCHAR(12),GETDATE(),108) AS '108', --hh:mi:ss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Haversine Formula based geodistance, calibrated for use in danish latitudes (6371 used as radius) | |
CREATE OR REPLACE FUNCTION service.geodistance(a point, b point) | |
RETURNS double precision AS | |
$BODY$ | |
SELECT acos( | |
sin(radians($1[0]))*sin(radians($2[0])) + | |
cos(radians($1[0]))*cos(radians($2[0]))*cos(radians($2[1])-radians($1[1])) | |
)*6371 AS distance; | |
$BODY$ | |
LANGUAGE sql IMMUTABLE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
void setup() | |
{ | |
Wire.begin(); | |
Serial.begin(9600); | |
Serial.println("\nI2C Scanner"); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bragil.dv-cpf) | |
; Realiza o cálculo do DV do CPF | |
(defn calc-dv [cpf-sem-dv] | |
"Calcula cada dígito do DV do CPF" | |
(def dv (mod | |
(* | |
(reduce + | |
(map-indexed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GeraDvCpf(string cpf) | |
{ | |
var semDv = cpf.Substring(0, 9); | |
int mod11 = (semDv.ToCharArray() | |
.Select((c, i) => Convert.ToInt32(c.ToString()) * (10 - i)) | |
.Sum() * 10) % 11; | |
// Primeiro dígito | |
int dig1 = mod11 > 9 ? 0 : mod11; |