sjevs / brazilcodesgenerator Goto Github PK
View Code? Open in Web Editor NEWBrazil Codes Generator
Brazil Codes Generator
Create a keyboard shortcuts for generation:
Suggestion:
Alt+G for dialog window to popup. Then select the code type with keyboard arrows/mouse or typing the name of code.
Hey Sergej,
If you want to add CNPJ creation too, here's a sample code (in Ruby) for a validity check:
def check_cnpj(cnpj=nil)
return false if cnpj.nil?
nulos = %w{11111111111111 22222222222222 33333333333333 44444444444444 55555555555555 66666666666666 77777777777777 88888888888888 99999999999999 00000000000000}
valor = cnpj.scan /[0-9]/
if valor.length == 14
unless nulos.member?(valor.join)
valor = valor.collect{|x| x.to_i}
soma = valor[0]*5+valor[1]*4+valor[2]*3+valor[3]*2+valor[4]*9+valor[5]*8+valor[6]*7+valor[7]*6+valor[8]*5+valor[9]*4+valor[10]*3+valor[11]*2
soma = soma - (11*(soma/11))
resultado1 = (soma==0 || soma==1) ? 0 : 11 - soma
if resultado1 == valor[12]
soma = valor[0]*6+valor[1]*5+valor[2]*4+valor[3]*3+valor[4]*2+valor[5]*9+valor[6]*8+valor[7]*7+valor[8]*6+valor[9]*5+valor[10]*4+valor[11]*3+valor[12]*2
soma = soma - (11*(soma/11))
resultado2 = (soma == 0 || soma == 1) ? 0 : 11 - soma
return true if resultado2 == valor[13] # CNPJ válido
end
end
end
return false # CNPJ inválido
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.