C type sizes

typebytesminmax
signed int4-21474836482147483647
unsigned int404294967295
signed char1-128127
char1-128127
unsigned char10255
signed short int2-3276832767
unsigned short int2065535
signed long int8-92233720368547758089223372036854775807
unsigned long int8018446744073709551615

Add a “New file” to the Windows 10 Context Menu

Have you ever thought that life would be made easier and more productive if you had a quick way of creating a file at your fingertips?

Windows has always been very picky about file extensions, and non-standard Microsoft file types can be a pain to create quickly, but there’s a neat trick to add these to the “New” menu.

First you need to open up the Windows Registry Editor application and expand HKEY_CLASSES_ROOT

Within this list, you will need to search for your desired file extension.

In my case, I want to add Python files to the Context Menu. I will need to find a folder in this list named .py as this is the file extension used for python files.

Similarly, if you wanted to quickly create a new html file, you would look for .html

You will need to add a new Key named : ShellNew.
Right click on your desired file extension and click New -> Key.
Name it : ShellNew

You should now see a new “Folder” called ShellNew:

The last step will be to add a new String Value to the ShellNew key, named NullFile.
Right Click on ShellNew : New -> String Value

Name this : NullFile.
Your Registry Editor should now look something like this:

You can now check your Context Menu to see if your changes worked!

Enjoy your productivity!

Lenovo 530S ARR – Slow Reboot/Shutdown

Since Demember 2018, I have been experiencing long reboots and shutdown times. Alot of people have pointed out that the Reaktek drivers might be to blame for this issue. Uninstalling the latest driver and using an older version does seem to “fix” the issue out (until Windows update decides to install the latest drivers again)

I decided to try my luck again and try and fix this problem, and I found the solution.

There wasn’t a newer Realtek driver available so i decided to update my Ryzen 5 Mobile Graphics drivers. The Graphics driver didn’t seem to fix the problem, so I moved on to the Ryzen Mobile chipset drivers.

After a quick reboot, it seemed to have fixed the issue!

NGINX : failed (2: No such file or directory) in /etc/nginx/nginx.conf

My first configuration of an NGINX server left me high and dry for a while. Coming from an Apache back-ground (where everything is done for you), NGINX felt a little archaic at first.
There was not much help out there for this issue so I will fill in the gap.

The error (in this case) was due to my symbolic link not being created correctly in sites-enabled.
I will go into a little more detail.

nginx: [emerg] open() "/etc/nginx/sites-enabled/mysite.co.uk" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62

This is the error (above) was being shown with any of the following commands :

  • Testing the configuration: sudo nginx -t
  • Starting or reloading the service:
    sudo service nginx restart
    sudo nginx -s reload
nginx: [emerg] open() "/etc/nginx/sites-enabled/mysite.co.uk" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62

This message is a bit vague, but there is a subtle hint here. The last path is pointing to the file containing the problem and the appended number correlates to the specific line number in that file.

In my case, line 62 was:
include /etc/nginx/sites-enabled/*;

I know the syntax of the line is correct because I compared it with the default file included in the installation.

Similar to Apache, the sites-enabled directory is meant to store symbolic links of configuration files that are stored in sites-available. Unlike Apache, however, the symbolic links need to be manually created by the admin, as apposed to an Apache command that automatically creates and removes the links when asked.

Navigating to /etc/nginx/sites-enabled, I checked the symbolic link using the following command

sudo ls -la lrwxrwxrwx 1 root root   32 Jul 19 20:16 mysite.co.uk -> sites-available/mysite.co.uk

I previously created this link whilst in the /etc/nginx folder using the following command:
sudo ln -s sites-available/mysite.co.uk sites-enabled/

Looking back at the ls output, the local filename is correct, however the file path that it is pointing to isn’t.
The correct path should be:
/etc/nginx/sites-available/mysite.co.uk

The solution was to simply create a new symbolic link to the configuration file, but using absolute paths instead of being lazy.

sudo ln -s /etc/nginx/sites-available/mysite.co.uk /etc/nginx/sites-enabled/

After this, NGINX complained no more and after a silent reload, instantly served my webpage on the World Wide Web. Nice.

Yes, this was complete user-error spurred from my lack of knowledge of symbolic links, however this is no longer a problem and I can get back to development.

Hopefully this will save someone else loads of time!

Linux vs Windows: Python Virtualenv

Although Virtualenv is available on both Linux and Windows, there are some differences that you may find useful to understand.

Is there a difference to creating virtualenvs?

No, creating virtualenvs in Windows and Linux is exactly the same.

Can I use the same venv folder on both systems?

No. You will need to create 2 separate virtual environments. I suggest creating folders named winvenv and linvenv to tell them apart. You will have access to the same packages through pip, although you will need to use pip freeze if you wanted to replicate the packages exactly.

Do I activate the venvs in the same way?

No, but you CAN activate, and the differences are subtle. After creating the virtualenv, follow these steps:

Windows

\winvenv\Scripts> activate

Navigate to Scripts within the venv root. Type activate to use your venv in the current prompt

Linux

$ source linvenv/bin/activate

In the terminal, type source followed by the path to /bin/activate within the viretualenv folder