Monday, March 14, 2016

Enable telnet client on windows

Somewhy telnet client not present in windows by default (well, once I've found it present by default in one server windows, but only once).
Here are algorithm - how to install in by standard tools - link.
backuped page:

C++ on windows and linux

Once I've encounted with problem - size of some variable on linux x86-64 differs from size of same variable on windows x86-64. And some years after that I couldn't remember - was it int or long or what. So here are link about it.
backuped article:
and here are another angry post about same problem)
backuped post:


So, problem in 'long' data type.

earlier I've used special macros to get DWORD == 4 bytes on x86 windows, x86-64 windows, x86 linux & x86-64 linux:
#if defined ( _MSC_VER )
    typedef unsigned long DWORD;
#else // for g++
    typedef unsigned int DWORD;
#endif

but now I would prefer _int32_t

Download file on windows by standard tools

Found interesting way - how to download file on windows only with standard tools (like how to make wget/curl on windows by standard tools) - [link]
and backuped article:
It can be useful, when you need do stuff like that and you don't add extra dependencies.

Sort file by lines lengths

Often I need to sort file by length of lines and always I can't remember code which is doing this.

my @elements;

while(my $line = <>){
    push @elements, $line;
}

@sorted = sort { length $a <=> length $b } @elements;

foreach my $l (@sorted){
   print($l);
}

OpenPGP and annoying pinentry window

Foreword

I've started to use PGP in jabber (GnuPG for windows - Gpg4win - I've used this instruction). Backup of instruction just in case:

 

Problem

And every time when I've got incoming message in jabber - appeared windows 'pinentry' and asked me password (passphrase). It's very annoying and in the internet I didn't find solution for Windows OS.
Window - looks like that:

Lyrics

So, in the internet there are lot of posts where people advices create file with properties - 'gpg-agent.conf', but usually it's about linux. Process monitor showed that in Windows this file expected to be in "C:\Users\username\AppData\Roaming\gnupg\gpg-agent.conf"

Action

  1. Create file "C:\Users\username\AppData\Roaming\gnupg\gpg-agent.conf"
  2. Write in this file 2 lines (values can be any big number - it's seconds of caching your password):
    • max-cache-ttl 2592000
    • default-cache-ttl 2592000
  3. Restart your gpg-agent.exe process