How to install Python of required version using PowerShell

by Dmitry Kirsanov 26. February 2023 11:46

 

One of the software packages I’m using, namely Stable Diffusion, requires a particular version of Python to work… Stable. Hence I made a little PowerShell script that would ensure that if there is a Python of lower version or it’s not installed, then it would be downloaded and installed automatically. Here it is: More...

HOSTS File Editor

by Dmitry Kirsanov 4. September 2019 10:57

HOSTS file is a text file in your Windows system that contains name resolution pairs to quickly resolve domain and LAN computer names, or ensure that resolution fails and host in question would become unreachable. We use it to speed up access to intranet hosts, block advertisement and telemetry websites, and in software development – to substitute real world hosts with local copies.

I have to edit HOSTS file often and on different computers. Supply IP addresses for local servers, block connection to Facebook, disable adverts in some apps, that kind of stuff. Well edited HOSTS file makes Windows work faster and helps avoiding problems with connectivity.

One problem, though – it’s over 60Kb large in my case, and adding / removing / temporarily disabling records - takes time. Not much, but more than I’d like to spend on that task. Therefore I felt the need for a command line editor – a single-command application, that would allow to perform the full range of operations on that file and make whole editing process a fraction of a second. And here it is. More...

Fixing yet another problem in Google Chrome

by Dmitry Kirsanov 10. June 2019 07:31

While digging into the problem with Chrome extension today, found that Chrome took around 700Mb of space for temporary files, which looked like CrashpadMetrics.pma~XXX.TMP. These files are 1Mb in size each, and there were literally over 700 of them.

Chrome creates these files to send to Google even if you disable this feature. Files aren’t sent, but created and never cleaned up.

I have a cleanup batch file on each computer, that executes every week, and it deals with drive(s) cleanup, synchronisation and stuff. I added this line:

ttl.exe "C:\Users\[my user name]\AppData\Local\Google\Chrome\User Data" /subs /days:30 /mask:*.tmp

This uses my TTL application to delete files older than 30 days. I could simply write “del crash*.tmp”, but what if there is a temporary file that’s currently being written, or might be used. Hence the TTL and generous 30 days.

The first run freed 685Mb on system drive.

File Backup automation tool

by Dmitry Kirsanov 7. March 2019 12:44

I think every system administrator is doing this often enough to think about automating it. When you make changes to file, deploy a new version and not sure if you’ll need to revert, and there is a number of previous copies that you would like to keep track of.

This little command line utility does exactly that – it creates the .bak file for whatever file, maintains any number of older backups (.bak1, .bak2 and so on), restores from .bak (this will also rename .bak2 to .bak1 and all older versions too), deletes all backups if needed, and can also keep backups in different directory – for cases when you are modifying file in publicly available directory or just don’t like clutter.

Get more information and binary on utility page

Making Chrome great again. Or, at least, bearable

by Dmitry Kirsanov 7. February 2019 11:27

One of the most hated parts of Google Chrome is it's Software Reporter Tool. This executable file is started by Chrome and supposedly is providing Google with logs from your computer. Either way, it's the fastest way to drain your laptop battery, make computer stutter and noisy. People often ask about the way to get rid of this software reporter tool, but the best advice they get is to modify the security permissions on executable file. Basically, the most common advice is to open the file settings, go to Security tab, ensure the security settings are not propagated from parent (in this case - directory) and then remove all access rights, making this file non-readable. Well, it only works till the next time Google Chrome updates.

A bit better way to lock this (or any other annoying) executable file is by using your Windows Group Policies. More...

Handling Temporary Files, Best Practice

by Dmitry Kirsanov 9. October 2016 05:59

Each day I am creating so many temporary files that I can’t really give you a count. Sometimes it’s thousands. Opening attachments from e-mails and instant messengers, saving images from internet for a single use, opening archives, deploying software and many other tasks – they all create temporary files that may stay in a hard drive for years.

By temporary files I don’t mean the files created by applications to temporarily store data. I mean the actual user files you don’t intend to use in the future.

Another type of temporary files is log files. Usually we have them on servers. Web server logs, mail server, your own application that creates a set of log files each day – usually you don’t need to store these files for more than a few months. Especially if these files are stored on virtual machines, like Azure or Amazon, where you are paying for each megabyte of storage.

There are two aspects in temporary files that may justify doing something about them:

1. They take space or they are produced in numbers that decrease the performance of file system. The file doesn’t have to take all the space of the drive – it’s enough to have thousands of files in one directory to make Windows freeze every time it’s trying to find and list these files. For some directories we would prefer to have a threshold of a particular time after which these files should vanish.

2. They may contain sensitive information that you wouldn’t want to leave behind. Of financial, medical, business, political or any other nature – when the file has expired, there is no need to keep it, but some files may require special care in form of secure erase. More...

Getting most from your SSD drive by redirecting directories

by Dmitry Kirsanov 5. July 2016 02:27

SSD are very popular these days. I can tell for myself - in all of my laptops I have SSD drives, and if it has more than one hard drive installed, at least one of them is SSD. My main laptop has rather interesting construction – it has only one standard size 2.5” hard drive, and a slot for M2 form factor SSD drive, which looks more like a microscheme than a “hard drive”. For me this means, that I have small capacity SSD (128Gb in my case) and large HDD, thus having good compromise between large capacity and performance.

With 128 and less of space, it doesn’t look like a good idea to migrate OS to such drive. Windows itself will take half of it, and then you would have to watch out for temporary files and whatever installation packages, so they wouldn’t install stuff that doesn’t require high performance storage, on SSD.

On the other hand, if you have a large existing hard drive with 500Gb of space taken over the years of work and play, migration to smaller SSD would be tricky. More...

How to install Chromium browser on Raspberry Pi 3 Raspbian Jessie

by Dmitry Kirsanov 20. June 2016 14:33

JessieI am working quite intensively with Raspberry Pi, and recently upgraded to both Raspberry Pi 3 and Raspbian Jessie, that was released during last quarter of 2015 and is currently the latest and greatest version of Raspbian.

The paramount part of my installation is Chromium browser, as these devices have to access website that is only compatible with Chromium-based browsers. And I found that if with previous Raspbian you could just run “aptitude install chromium” and it would install the browser, now you are getting message “no candidate version found for chromium” and nothing gets installed.

To overcome this issue and install Chromium, you need to download and install three packages. Here is the exact script of what you need to run in console: More...

Sending e-mails from the cloud based web application

by DmitryKirsanov 10. June 2016 06:26

 

 

This sounds crazy. But when you move your website to the cloud, you get problems in things you were previously taking for granted. Like sending e-mails. Basically, the problem is that many e-mail servers, usually ones of big providers, have Azure, Amazon and other cloud provider IPs blacklisted. When you attempt to use SMTP service from your virtual machine in Azure – in many cases it fails to deliver. This means, that your Azure machine can not act as mail server and shouldn’t attempt to deliver messages to recipient SMTP server directly.

Why would you use SMTP service at all? Well, mainly for the sake of performance. Your web application, be it ASP.NET, PHP, Ruby or whatever, will benefit from saving the outgoing e-mail message as text file somewhere on local hard drive, instead of trying to deliver it using TCP/IP, even if that’s done in asynchronous method.

More...

Restoring Access to Microsoft SQL Server

by Dmitry Kirsanov 26. August 2013 05:29

As a note to system administrator – what to do, when your one and only administrators account is locked on your SQL Server.

You need to perform 5 quick steps. More...