Is there a replacement for unistd.h for Windows (Visual C)?

Since we can’t find a version on the Internet, let’s start one here. Most ports to Windows probably only need a subset of the complete Unix file. Here’s a starting point. Please add definitions as needed. #ifndef _UNISTD_H #define _UNISTD_H 1 /* This is intended as a drop-in replacement for unistd.h on Windows. * Please … Read more

Why does glibc’s strlen need to be so complicated to run quickly?

You don’t need and you should never write code like that – especially if you’re not a C compiler / standard library vendor. It is code used to implement strlen with some very questionable speed hacks and assumptions (that are not tested with assertions or mentioned in the comments): unsigned long is either 4 or … Read more

Why should I not #include ?

Including <bits/stdc++.h> appears to be an increasingly common thing to see on Stack Overflow, perhaps something newly added to a national curriculum in the current academic year. I imagine the advantages are vaguely given thus: You only need write one #include line. You do not need to look up which standard header everything is in. … Read more

Is there a portable way to get the current username in Python?

Look at getpass module import getpass getpass.getuser() ‘kostya’ Availability: Unix, Windows p.s. Per comment below “this function looks at the values of various environment variables to determine the user name. Therefore, this function should not be relied on for access control purposes (or possibly any other purpose, since it allows any user to impersonate any … Read more

How do SO_REUSEADDR and SO_REUSEPORT differ?

Welcome to the wonderful world of portability… or rather the lack of it. Before we start analyzing these two options in detail and take a deeper look how different operating systems handle them, it should be noted that the BSD socket implementation is the mother of all socket implementations. Basically all other systems copied the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)