Month: August 2017

  • Fingerprint cannot be generated while adding new ssh key in GitLab

    This applies to Windows only machines.

    I have GitLab running and was adding a new ‘ssh key’ from windows that was generated using a standard ssk-keygen command but was reciving following error:

    “Fingerprint cannot be generated”

    Command used to generate key:

     ssh-keygen -t rsa -C "gbugaj@localhost" -b 4096
    

    This produces a key in ‘id_rsa.pub’ file, from there I cated that file and copies the content of if by ‘HIGHLIGHTING’ directly in the command window.

    This is the result that got when pasted it

    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDuer2ZkTKwsirssZTBaJiyr/GpALglr6X9Ct2cysvgYs05SEvz+B66US4bFv5IVwiOEXJ51oR0EF0/oDv4Juq1zzvydX44rdKFwlL7Qq7Uezxw4FCJotn/wZqpuaScNszP8/gvZY82j9HCYmITFWobwk1JGvQnezbZ
    KsaUtUEQwnptYbWvOZ9yNRRzwkntafOBS2l18wJNl6bjHHUJ6NIzRMudvd7/AjqP5qWL3GjJ9ecyHU0Dox3fIAfzlMRhKCQswPos7i35GWtLBzaOfeqJ2iZA2eGjfh1cGW71hyvO72+rxjjXk3uUvSqFP+WWSrt8VdJJqXfhk0RFqDxcUku6fRWeALp0qWna6Qm8/CbF
    rw0t0s0bF557GqaJCIyMEqj+OVMpcMYCTStnjuTNM8OIz/A3BCJbwt9GsojyFUYesfA0i/4tt9MPYAfcPxO914IYn3mq7Qcvq7RgTJPgM8SGY+SIpACjFKaF6wOf91oa105PcPY4yvISLa40GivN0K871yjo/2Jwq6w6ZE601LD0FngWhrfKejueKucvNvYtdR/aX7LL
    Oq6md0HK6ybIGKJH2qph3+GJP/AUAf85bhWe1mPw3woZ28bWjo+Kp5zeTJqtd6QTDWTkDftsQJcmMgT43lViJBqChTTA/oGiXiV62PMKMeMCDaTYNkuZZvLE8Q== gbugaj@localhost
    

    As you see here lines are split, this is the problem. To solve this we just need to open the file in some editor and copy it from there so all the text is on one line.

    ssh-rsa AAAB3NzaC1yc2EAAAADAQABAAACAQDuer2ZkTKwsirssZTBaJiyr/GpALglr6X9Ct2cysvgYs05SEvz+B66US4bFv5IVwiOEXJ51oR0EF0/oDv4Juq1zzvydX44rdKFwlL7Qq7Uezxw4FCJotn/wZqpuaScNszP8/gvZY82j9HCYmITFWobwk1JGvQnezbZ
    KsaUtUEQwnptYbWvOZ9yNRRzwkntafOBS2l18wJNl6bjHHUJ6NIzRMudvd7/AjqP5qWL3GjJ9ecyHU0Dox3fIAfzlMRhKCQswPos7i35GWtLBzaOfeqJ2iZA2eGjfh1cGW71hyvO72+rxjjXk3uUvSqFP+WWSrt8VdJJqXfhk0RFqDxcUku6fRWeALp0qWna6Qm8/CbFrw0t0s0bF557GqaJCIyMEqj+OVMpcMYCTStnjuTNM8OIz/A3BCJbwt9GsojyFUYesfA0i/4tt9MPYAfcPxO914IYn3mq7Qcvq7RgTJPgM8SGY+SIpACjFKaF6wOf91oa105PcPY4yvISLa40GivN0K871yjo/2Jwq6w6ZE601LD0FngWhrfKejueKucvNvYtdR/aX7LLOq6md0HK6ybIGKJH2qph3+GJP/AUAf85bhWe1mPw3woZ28bWjo+Kp5zeTJqtd6QTDWTkDftsQJcmMgT43lViJBqChTTA/oGiXiV62PMKMeMCDaTYNkuZZvLE8Q== gbugaj@localhost
    
  • Overloading by return value in C++

    Here we have a method that allows us to determine return parameter type using templates and operator overloading in C++. This is something that I needed for a project that I am working on where a method call would give me the expected type based on the return type.

    Usage

    There is two way of using this. First one is by calling the para method and second one is by invoking the conversion method directly parameter.
    Personally, I prefer the first one as this one allows me to use it with auto keyword.

    
    std::string p0   = param<std::string>(arguments, 0);
    auto        p0_a = param<std::string>(arguments, 0);
    
    int         p1   = param<int>(arguments, 1);
    auto        p1_a = param<int>(arguments, 1);
    
    // Invoking parameter conversion directly
    std::string p0_p = parameter(arguments, 0); 
    int         p1_p = parameter(arguments, 1);
    

    Implemenation

    struct parameter
    {
    	parameter(const CefV8ValueList & arguments, int index) 
    		:_arg (arguments.at(index)) 
    	{
    	};
    
    	operator std::string() { return _arg->GetStringValue().ToString(); }
    	operator int() { return _arg->GetIntValue();}
    	operator bool() { return _arg->GetBoolValue(); }
    	operator double() { return _arg->GetDoubleValue();}
    
    	CefRefPtr _arg;
    };
    
    template
    T param(const CefV8ValueList & arguments, int index)
    {
    	return parameter(arguments, index);
    }
    

    Reference :
    http://en.cppreference.com/w/cpp/language/cast_operator