Coder Social home page Coder Social logo

brazilcodesgenerator's People

Stargazers

 avatar

Watchers

 avatar

brazilcodesgenerator's Issues

Keyboard shortcut

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.

CNPJ

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.