python – Improving a Medicare Beneficiary Identifier (MBI) generator

I am new to coding and looking for a few pointers on how I can improve my first project.

At work, I often need to create Medicare Beneficiary Identifiers (MBI) when creating test patients with Medicare coverage, and have to look up the format every time. I thought creating an MBI generator would be a great first project.
Doing a quick search, I found a similar project on this site (which is what lead me here), but the questioner wants to create 10,000 records, whereas I may only need one or two MBIs at a time (their question can be found here: Sequential MBI generator). Being new and not understanding all of the code, I was nervous to follow in their path and end up with a ton of records, so I actually followed an example of a random password generator and tweaked it to meet my needs. As the outcome is vastly different from the linked example and seems verbose, I wondered if anyone with more experience would be able to give me some pointers to get me off to improve my work.

    #MBI is 11 characters in the following format 
     # 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11
     # C - A - AN- N - A - AN- N - A - A - N  - N
     # C = Numeric 1 - 9
     # N = Numeric 0 - 9
     # A = Alphabetic A...Z; Not S, L, O, I, B, Z
     # AN = Either A or N

    import random
    letter = 'ACDEFGHJKMNPQRTUVWXY' # not = B, I, L, O, S, Z
    digit = str('0123456789')
    partdig = str('123456789')
    dig_let = digit + letter

    while 1:
         mbi_return = 1
         mbi_need = int(input("How many MBI numbers do you need to generate?: "))
          for x in range(0,mbi_need):
             mbi = ""
             for x in range(0, mbi_return):
                mbi_char0 = random.choice(partdig)
                mbi_char1 = random.choice(letter)
                mbi_char2 = random.choice(dig_let)
                mbi_char3 = random.choice(digit)
                mbi_char4 = random.choice(letter)
                mbi_char5 = random.choice(dig_let)
                mbi_char6 = random.choice(digit)
                mbi_char7 = random.choice(letter)
                mbi_char8 = random.choice(letter)
                mbi_char9 = random.choice(digit)
                mbi_char10 = random.choice(digit)
                mbi = (mbi_char0 + mbi_char1 + mbi_char2 + mbi_char3 + mbi_char4 + mbi_char5 + 
                mbi_char6 + mbi_char7 + mbi_char8 + mbi_char9 + mbi_char10) # I imagine this could be much cleaner
                print(mbi)

Thanks in advance!

oracle – PLS-00201: identifier UTIL_FILE must be declared

I’m trying to write a procedure for exporting some data as a CSV:

CREATE OR REPLACE PROCEDURE CONSTRUCT_CSV AS
  
  F1 UTL_FILE.FILE_TYPE;
  CURSOR c_data IS
    SELECT construct_id,
           construct,
           n_term,
           enz_name,
           c_term,
           cpp,
           mutations,
           mw_kda
    FROM   construct
    ORDER BY construct_id; 
     
BEGIN 
    F1 := UTL_FILE.FOPEN( location => 'EXTRACT_DIR',
                          filename => '1_CONSTRUCT.txt',
                          open_mode => 'w',
                          max_linesize => 32767);
    FOR cur_rec IN c_data LOOP 
        UTL.FILE.PUT_LINE (F1, 
                            cur_rec.construct_id || ',' ||
                            cur_rec.construct || ',' ||
                            cur_rec.n_term || ',' ||
                            cur_rec.enz_name || ',' ||
                            cur_rec.c_term || ',' ||
                            cur_rec.cpp || ',' ||
                            cur_rec.mutations || ',' ||
                            cur_rec.mw_kda);
                            
    END LOOP;
    UTL.FILE.FCLOSE(F1);
END;
/

I get an error that says:

LINE/COL  ERROR
--------- -------------------------------------------------------------
22/9      PLS-00201: identifier 'UTL.FILE' must be declared
22/9      PL/SQL: Statement ignored
33/5      PLS-00201: identifier 'UTL.FILE' must be declared
33/5      PL/SQL: Statement ignored
Errors: check compiler log

This post suggests that this issue can be fixed by granting the user privileges as sysdba. I did that, but I still get the same error.

enter image description here

oracle – How to quote sqlplus identifier in bash script

I have googled for an hour or so now and still can not find how to quote a sqlplus identifier in bash script.

I get “ORA-00904: “MEMORY_TARGET”: invalid identifier” no matter how I try to quote the identifier in the following command

MEMORY_TARGET=$(su – orat01 -c ” echo ‘select VALUE from V$PARAMETER where name = ‘memory_target’;’| sqlplus / as sysdba “)

Any ideas on how to do this would be greatly appreciated.

javascript – Erro com arquivo.js: Unexpected identifier

Estou com um problema no código quando inicializa (linha 176, marquei com um *)

var tabuleiro = document.getElementById('tab')
var espacos = document.getElementsByName('espacos')
var botao_reiniciar = document.getElementById('botao_reiniciar')

var Menu_Versus_X = document.getElementById('Menu_Versus_X')             //menu, para mudar a cor, desing indicativo de quem vai jogar
var Menu_Versus_O = document.getElementById('Menu_Versus_O')

var pontos_X = 0
var pontos_O = 0
var vitoria = false                       
var placar = document.getElementById('placar')
var contagem_para_empate = 0
//----------Variável nescessária para a condição de quem esta jogando (Quem_Joga)(Condição 1*) e escolha aleatória de quem comeca--------

var opcoes = ("X","O");
var Quem_Joga = ((opcoes(Math.random() < 0.5 ? 0 : 1)));
window.alert(`'${Quem_Joga}' começa! O jogo vai até 3 pontos!`)

//----------------------------------------------------------------------------------------

function Selecionar_Espaco(){  //(JOGO SE BASEA NESSA FUNCTION)
    
    if (vitoria == false) {                  //se a vitória for false, continue o jogo, se vitoria for true, ele acaba
        
        var espaco_selecionado = event.target   //Identificação de qual div (a1, a2...) o jogador esta clicando

         //------------------------ERRO se a casa clicada ja estiver selecionada-----------------------------------------------------
        if (espaco_selecionado.innerHTML == 'X' || espaco_selecionado.innerHTML == 'O' || espaco_selecionado == tabuleiro){  
            window.alert('Casa já selecionada!')
            return
        }
        //------------------------------------------------------------------------------------------------------

        contagem_para_empate += 1                //se ela ficar = 9 o progama da empate (9 quadrados) (*3)

        //----------------------------------QUEM TA JOGANDO X--------------------------------------

        if (Quem_Joga == 'X'){ //(1*)       //Jogador1: marcação da casa e analise de qual jogador vai jogar
            Menu_Versus_X.style.color = 'black'
            Menu_Versus_O.style.color = 'greenyellow'
            espaco_selecionado.innerHTML = 'X'
            Quem_Joga = 'O'                //Quando o jogador1 jogar, tal recebe 'O' (quer dizer que a proxima condicao(1*) sera falsa, passando a vez para o jogador2(2*)) 

//----------------------------------------------------CONDICOES DE VITORIA JOGADOR X---------------------------------------------------------
        if ((a1.innerHTML == 'X' && a2.innerHTML == 'X' && a3.innerHTML == 'X') || (b1.innerHTML == 'X' &&  b2.innerHTML == 'X' && b3.innerHTML == 'X') || (c1.innerHTML == 'X' && c2.innerHTML == 'X' && c3.innerHTML == 'X') || (a1.innerHTML == 'X' && b2.innerHTML == 'X' && c3.innerHTML == 'X') || (a3.innerHTML == 'X' && b2.innerHTML == 'X' && c1.innerHTML == 'X') || (a1.innerHTML == 'X' && b1.innerHTML == 'X' && c1.innerHTML == 'X') || (a2.innerHTML == 'X' && b2.innerHTML == 'X' && c2.innerHTML == 'X') || (a3.innerHTML == 'X' && b3.innerHTML == 'X' && c3.innerHTML == 'X')){     

            if (pontos_X < 2){     
                pontos_X += 1
                contagem_para_empate = 0
                window.alert(` Rodada ganhada pelo jogador1 ( X ) ! `)
                espacos.forEach(function(n){
                    n.innerHTML = '';
                })

            }else{           //Se o ponto de X for NÃO for menor que dois (quer dizer q vai ser  = 3) entao ele ganha (vai ate 3 pontos)
                window.alert('VITORIA DO JOGADOR1 ( X )')
                pontos_X += 1
                vitoria = true
                Menu_Versus_O.style.color = 'red'
                Menu_Versus_X.style.color = 'blue'
            }

        }
        //------------------------------------------------------------------------------------------------------------------------------------

            //----------------------------------QUEM TA JOGANDO O--------------------------------------
        }else{ //(2*)  
            espaco_selecionado.innerHTML = 'O'        //Jogador2
            Quem_Joga = 'X'
            Menu_Versus_O.style.color = 'black'
            Menu_Versus_X.style.color = 'greenyellow'

            //------------------------------------------CONDICOES DE VITORIA JOGADOR O---------------------------------------------------------
            if ((a1.innerHTML == 'O' && a2.innerHTML == 'O' && a3.innerHTML == 'O') || (b1.innerHTML == 'O' &&  b2.innerHTML == 'O' && b3.innerHTML == 'O') || (c1.innerHTML == 'O' && c2.innerHTML == 'O' && c3.innerHTML == 'O') || (a1.innerHTML == 'O' && b2.innerHTML == 'O' && c3.innerHTML == 'O') || (a3.innerHTML == 'O' && b2.innerHTML == 'O' && c1.innerHTML == 'O') || (a1.innerHTML == 'O' && b1.innerHTML == 'O'  && c1.innerHTML == 'O') || (a2.innerHTML == 'O' && b2.innerHTML == 'O' && c2.innerHTML == 'O') || (a3.innerHTML == 'O' && b3.innerHTML == 'O' && c3.innerHTML == 'O')){     

                if (pontos_O < 2){     
                    pontos_O += 1
                    window.alert(` Rodada ganhada pelo jogador1 ( O ) ! `)
                    contagem_para_empate = 0
*                    espacos.forEach(function(n){
                        n.innerHTML = '';
                    })

                }else{
                    window.alert('VITORIA DO JOGADOR1 ( O )')
                    pontos_O += 1
                    vitoria = true
                    Menu_Versus_X.style.color = 'red'
                    Menu_Versus_O.style.color = 'blue'
                }

            }
            //------------------------------------------------------------------------------------------------------------------------------
        }

        placar.innerHTML = `<fieldset>${pontos_X} X ${pontos_O}</fieldset>` //mudanca do placar se tiver vitoria (esta dentro do bloco (if vitoria = false))

        //--------------------------------------EMPATE---------------------------------------------------
        if (contagem_para_empate == 9){  //(*3)
                window.alert('EMPATE')
                contagem_para_empate = 0

                espacos.forEach(function(n){
                    n.innerHTML = '';
                })
            }
        //------------------------------------------------------------------------------------------
        
    }   

}

//----------Reinicia pontos, placar, contagem_empate - coloca vitora como false novamente - escolhe um player - limpa a tabela---------------
function reiniciar(){
    espacos.forEach(function(n){
        n.innerHTML = '';
    });

    pontos_O = 0
    pontos_X = 0
    contagem_para_empate = 0
    vitoria = false

    Quem_Joga = ((opcoes(Math.random() < 0.5 ? 0 : 1)));
    window.alert(`'${Quem_Joga}' começa! O jogo vai até 3 pontos!`)

    placar.innerHTML = `<fieldset>${pontos_X} X ${pontos_O}</fieldset>`
    Menu_Versus_O.style.color = 'black'
    Menu_Versus_X.style.color = 'black'
}

Encryption – Can the name and date of birth be hashed in some way to generate a secure identifier?

I am working on a project that we want to launch for developing countries, so I want to limit the amount of information needed for registration and identification, while ensuring individual privacy and security.

Speaking to the team, it became clear that passwords are not a problem, as users may only be able to access the service if they are given a third-party access to the Internet (even once or twice a year). Saving passwords, using emails or the like would not work in this scenario.

The whole thing is that I need to store some data about each user and I don't want to have any idea what the data is. It's not particularly sensitive data, but I'm trying to create something that protects privacy as much as possible.

So I wonder how I can identify users with information they contain knows and do not have to bet any extra effort in remembrance.

As a result, we have limited the usable information to the following: full name and date of birth (even DoB can be a problem for some). Intuitively, it doesn't look like you can build something very secure with this data. A major mistake in name and DoB is that you can easily go through all combinations for "John Smith" with all possible dates of birth and find a suitable hash.

Therefore, a rough solution is to hash the name and the DoB and use it as a "username" (of course everything happens in the background). Some additional measures would be to encrypt the date of birth and add salt to the hash.

The authentication would then take place via face recognition. The idea is to encrypt an image of the user with a combination of name and DoB so that it is at least not so easily accessible to the database administrator.

A user only logs on with their name, DoB and picture in a system that first searches the hashes until a match is found, then decrypts the corresponding picture and compares the two pictures to enable the registration or not.

In summary, the user credentials would be something like this:

SHA256(NAME + SCRAMBLED_DOB + SALT) => AES(PICTURE_DATA, (NAME+SCRAMBLED_DOB))

The salt could also be added to encrypt the image so that when you log in:

  1. All possible versions of SCRAMBLED_DOB are tested with several salts until a hash is found in the database
  2. This specific hash and the sequence of digits from the DoB from step 1 are used to decrypt the image
  3. The image is compared with the image submitted when logging in, which is then discarded

This process can take a long time, but it depends How longit may be acceptable in the name of privacy.

So I'm essentially asking myself:

  1. Would SHA256(NAME + SCRAMBLED_DOB + SALT) be sure enough given the project's requirements?
  2. Any suggestions for a better way to encrypt the image?
  3. Any suggestions for this system as a whole?

Thank you in advance!

Lens – What is the advantage if no names, but only descriptions are used as a unique identifier for lenses?

Am I right when I observe that lenses have no names …?

No.Lenses have names, multiple names such as model numbers and FCC IDs. Manufacturers need to be able to track what they manufacture and sell. Some manufacturers also give their lenses marketing names.

Since model numbers often do not contain information that consumers need to decide whether to buy a lens, the specifications themselves also serve as a (general) name. Most manufacturers have only one electricity Lens model with a specific set of specifications. Consumers can refer to lenses with abbreviated names like "Nikon 18-55mm" and there is usually only one current fitting model. More information is needed when looking at used lenses, but it's not that difficult. If you don't remember whether you want the v1 or v2 lens, it probably doesn't matter. If it matters, write it down, bookmark the review, or ask Google.

… when I search for a new lens, I can never find a model number.

Whether you can find the model number is a different question than whether it exists. Some manufacturers' model numbers may only be used for internal use (not well known).

A quick search on the Nikon website shows that the model number for one of the Nikon kit lenses listed above is: AFS18-55_3.5-5.6GVRII_NT (7C_DL). Note that it is similar to the common name, with no spaces or units. By learning the common name, you effectively use the model number.

… it must have an advantage to use descriptions for lenses.

Common names (what you call descriptions) are easier to remember than any model number. People are also usually more interested in the specifications that determine how the product is used. Assume that a company would introduce Elijah and Elisha lenses. Are you going to buy them based on their names? Wouldn't you be interested in the technical data? Someone looking for a 35mm lens can safely skip reviews of 85mm lenses.

I heard that lenses used to have names, but it got confusing.

Marketing names are confusing. For example, what are the differences between Pancolar, Planar, Sonnar, Biotar, Biometar, Minitar, Lomogon, Xenon, Xenar, Hexanon, Hexar, Rokkor, Celtic, …? What if I told you that these names more or less, refer to 50 mm lenses for different camera systems? If you only have one camera system, just knowing that you want 50 / 1.8 is enough to get the right one.

Oops, two of these lenses are 32mm … that's the foolishness to rely on that kind of name. They remember the name, but still get the wrong lens.

You need to know either the bracket or the bezel to distinguish them.

It's not too much to expect people to know which mount they need for their camera. At least most people know which camera they are using. Most sellers can use this information to determine delivery.

Can someone explain the difference between lenses and other consumer electronics?

Marketing names don't tell people about how the product is used. For products such as cars, televisions, and cameras, usage is determined by the product type. However, the use of lenses is subject to certain specifications. If you need a certain field of view, you need to find lenses with certain focal lengths. If you want to shoot in a 1: 1 ratio, you need a macro lens. Fancy names do not convey this information.

Lens – Why don't we use names, just descriptions as a unique identifier for lenses?

  1. Am I right when I observe that lenses have no names, or should I see the manufacturer's description as the only correct name, and is a variation of it a spelling mistake?

A lens is a tool, part of the camera system. If I ask you to grab a socket wrench, I've given you a useless description of the tools you need. If you are asked if you want to grab a 3/8 ”socket wrench, a 12” extension and a 1/2 ”socket, you now know what you have to buy for me.

The same applies to a lens. If I say grab me in a wide angle, guess. When I say I want a 16-35mm f / 2.8, you now know what I need.

These things don't need names because they have one: lens. As with all tools, we select them based on their function and communicate about them.

  1. How do lenses and cameras differ? Why does one have a unique name and the other one doesn't? My working hypothesis is that you probably have multiple lenses and want to differentiate them by their unique properties, but in practice I label them with their purpose / reason why I bought them.

See the tool point above. You buy a drill with a marketable name, but every piece you buy is named for its function.

Have you seen the data sheet for a camera? There are many, many functions – a name that encompasses all would be ridiculous. So you get model names to market and compare.

A lens has two important pieces of information: focal length and maximum aperture – done.

Manufacturers are asking for additional money for a quieter / more precise focus motor, ED glass, stabilization, etc., so you can't seriously claim that they are not important.

I have never made such a claim. I have claimed that the focal length and aperture are crucial for the shot, while in most cases the rest is "nice to have".

If I go to a soccer game during the day, I will tell you that I want a 70-200 f / 4 and a 400 f / 5.6 with me. Of course, if you offered me a 70-200 f / 2.8 or a 400 f / 4, I wouldn't say no, but I could work with less.

The fact that these lenses have USM technology or fantastic glass is great, but not nearly as critical to my decision-making process as focal length and aperture. For example, I would take a manual focus lens with the right focal length and aperture for my needs over a super new and super cool auto focus lens in the wrong focal length range.

Yes, there are other features of a lens – but the focal length and aperture range determine whether you can take your intended shot or not.

mysql – Error in StoredProcedure: is not valid at this position and expects an identifier

I am new to MySQL. I've always used SQL Server, but I really need to learn new things

I am doing a login stored procedure but it is sending me an error

is not valid at this position and expects an identifier

CREATE PROCEDURE `sp_login` (@u varchar(50), @p varchar(100))
As
DECLARE @ap varchar(50)
BEGIN
SELECT @ap=passwd FROM transportesclaudia.usuarios WHERE login=@u

IF @ap IS NULL
RETURN -1
ELSE
IF @ap=@p
RETURN 1
ELSE
RETURN -2

END

Lens – Why don't lenses have names, just a description as a unique identifier?

When I had my first DSLR, I was confused that lenses were identified by their properties and did not have a unique model name (or model number).

I have a camera. If I called it a Nikon 20.9 Mp 51 AF DX Camera I probably narrowed it down to the model I have. However, the model is marketed under the name D7500. However, when I want to label a lens, I only have its specifications, such as: Nikon 18-55mm VR II or AF-S DX Micro NIKKOR 40mm f/2.8G. This annoys me for several reasons, but mainly because of the consistency.

E.g. the AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED II it seems to be Nikon AF-S DX Zoom-Nikkor 18-55mm 1:3.5-5.6G ED II Lens Black. This makes it difficult to search and compare. And many terms could easily be "misspelled". Nikkor or Nikon shouldn't matter 1:2.8 and /f 2,8 are interchangeable. Is it also important in which order I place the specifications?

It also makes it very difficult to remember. Let's take the hypothetical situation where I go to a store to buy a lens with a good rating. I have to remember every single letter in the name to avoid coming with version I instead of II or the one without ED glass and / or home or VR.

I heard that lenses used to have names, but it got confusing. But what can be more confusing than not having a name at all?

As a side note, I recently found an exception to the rule, the Nikon Noct, although technically it's the second lens with that name and doesn't do anything to avoid confusion: you still need to know either the bracket or opening to distinguish them.

My questions are:

  1. Am I right when I observe that lenses have no names, or should I see the manufacturer's description as the only correct name, and is a variation of it a spelling mistake?

  2. How do lenses and cameras differ? Why does one have a unique name and the other one doesn't? My working hypothesis is that you probably have multiple lenses and want to differentiate them by their unique properties, but in practice I label them with their purpose / reason why I bought them.