Golang. Number into words

Let’s write a program that prints numbers as text. Let’s limit it to a range of 1 to 1000.

Here is the first example of code, a fuzzy one:

Continue reading

Posted in Go (en) | Leave a comment

Golang: Newton’s algorithm

Task number 8 in golang tour…

Cycles and functions

To play with functions and loops, let’s implement the square root function: Given a number x, we want to find the number z for which z² is closest to x.

Computers usually calculate the square root of x using a loop. Starting with some assumed z, we can adjust z based on how close z² is to x, getting a better guess:

z -= (z * z - x) / (2 * z)

igroglaz’ note: Continue reading

Posted in Go (en) | Leave a comment

Golang. The average of the numbers entered in the string

Let’s write a program that reads N numbers separated by a space (in one line) and calculates their average value.

The task seems to be simple, but it can be solved in different ways. Here is my version:

Continue reading

Posted in Go (en) | Leave a comment

Golang. Median

Today let’s remember what the median is and how to find it. The median is a number exactly in the middle of an ordered list. It is a very useful thing in statistics and it helps to see the real picture, not the average temperature in the hospital 🙂 For example, we have a list of 55, 1, 22, 7, 92… to find the median:

  1. we order it. We get: 1, 7, 22, 55, 92
  2. look for the one in the middle… that’s 22

If we have an even number of elements in the list, then the median is the average of the sum of two neighboring values. Anyway, here is the code of the simplest variant:

Continue reading

Posted in Go (en) | Leave a comment

Golang. Number of letters in a sentence

Calculate the number of characters in the text – how many which letter occurs how many times. You can do this with maps, but there is another, C-style way: character arithmetic:

Continue reading

Posted in Go (en) | Leave a comment

Golang. Funny basic example of `if/else`

There is a resource for newcomers to the Go language – “A Tour of Go“. There’s a funny example in the beginning by number 7.. Continue reading

Posted in Go (en) | Leave a comment

Golang. Simple programs for beginners

The Go language is very similar to C. Here are some simple programs.

Let’s begin… Calculate 2 to the 12th power.

Continue reading

Posted in Go (en) | Leave a comment

Run notepad++ from the Windows console

Sometimes in Windows, you have to use cmd console, create files in it, etc. So it is convenient to bind file opening in npp (notepad++) to alias npp <file name>. There are different ways to do it, but the easiest is this:

1. create a .bat file named npp.bat and write there

@echo off start "" "C:\Program Files\Notepad++\notepad++.exe" %*

2. we just put it into the folder C:\Windows

Hallelujah! Now you can open files in your favorite npp from the console 🙂

Posted in Notepad++ (en) | Leave a comment

CodeBlocks debugging global variables

I love CodeBlocks IDE for my C language projects… But biggest blunder of CodeBlocks IDE is that you must manually add to ‘Watch’ global variables every @#$% time when debugging. Eg in C++ Builder and other IDEs there is no such problem… Why, why they did it?..

Ok, ok.. “One should avoid to use global variables”, – many will say. But using globals for tiny programs it’s actually the most convenient way to do fast tasks. And AFAIK most of the projects which use CodeBlocks is actually enthusiasts projects.. So it’s really out of scope feature there.

Posted in IDE (en) | Leave a comment

Returning the old terminal after Windows 11 update KB5019509

Got the update for Windows today – KB5019509 and the terminal’s arm was torn off. That is, it stopped displaying console programs like my Roguelike game. The update that broke it, adds tabs to the console, while breaking everything else… well, not the point (by the way, to see the latest Windows updates, type wmic qfe list into cmd).

To fix it:

Click on the header of the terminal window -> Properties

In Default Terminal Application put Windows Console Host

Restart the console and hallelujah! We got our oldschool console back. Old Billy’s nose lost the game again ;P

Posted in Windows 11 (en) | Leave a comment

Add “New” .txt in Windows 11 to the context menu

Add “New” .txt in Windows 11 to the context menu

Windows Registry Editor Version 5.00
@="Text File"

Run it, kill the explorer and enjoy the ability to create .txt files 😉

Continue reading

Posted in Windows 11 (en) | Leave a comment

Remove “New” file types from the context menu in Windows 11

I switched to Windows 11 with a crunch. Terrible interface. Billy, why?!

In general, one of the crutches that you have to substitute in order not to go crazy – removing @#$% file types from the context menu “New”. It’s done like this (works on Win 10 as well):

  • regedit
  • look for the right extension, e.g. .odg (OMG, why does LibreOffice add his holey hats there).
  • There, look for the ShellNew section and delete the hell out of it (Billy, they’re waiting for you there with a really hot pan).
Posted in Windows 11 (en) | Leave a comment

What do you program in Python? Real-world applications with library examples

When I started learning Python, I got curious about what people write in this language. If you look at it from a general perspective, it seems like Python is used everywhere – it’s such a super universal language that you can write computer games, create a social network with pictures, make a website, and whatever else you want. Just learn Python and you can program whatever you want,
anything you want. It’s like saying that it’s like an entire house is built out of plaster… it’s only covered in plaster, but it’s built with concrete, for example. Python is plaster in that sense.
Continue reading

Posted in Python (en) | Leave a comment

Top 3 programming languages for beginners. Which first programming language should I choose?

As a beginner programmer you have probably already racked your brains thinking about which programming language to choose. I have chosen three options, and now I will explain which one is right for you.
Three of the best first programming languages right now:
  • C language
  • Python
  • JavaScript

Continue reading

Posted in Programming (en) | Leave a comment

Assembly cheatsheet

Assembler is a low-level programming language. Below it there is only machine code (zeros and ones).

Why learn assembler?

  1. To understand how a computer works. Any programmer must know C. Any programmer who knows C must know Assembler.
  2. The ability to reverse engineer software (we live in a copyist world). For me this is first of all the vintage games of the 90s, the sources of which have not survived.
  3. ok. commercial development. If your device doesn’t have enough memory. – You write in asm. Microcontrollers, loaders, embedded software. If you need everything to run faster than lightning for a particular system – you also write directly to the processor, this is more efficient.
  4. WebAssembly (wasm) 🙂 This is not a programming language, but a technology that is now taking over the web. You don’t have to write in assembler there, but it is useful to understand assembler for code optimization.
  5. And analysis of all sorts of viral crap. Computer security and anti-virus labs are where assembler comes in handy.

Continue reading

Posted in Assembly | Leave a comment

Hello World in Assembly x86

Hello World in assembly language. How much fun is in that! For starters, here’s what we’re going to dig into in asm, the classics:

#include <stdio.h>
int main(void)
    printf("Hello, world\n");
    return 0;

On GNU assembly it would be something like this:
Continue reading

Posted in Assembly | Leave a comment

C language: “can’t bind to the port” problem (Windows)

Sometimes your program process can stuck and trigger error like this:

Couldn’t bind to the port

Ok, we have such check in out sockets C code:

if (bind (socket_desc, (struct sockaddr*)&server_addr, sizeof(server_addr)) < 0)
printf("Couldn't bind to the port\n");

And it return negative value.. How to fix it?

  1. find which process using this port via cmd:
    netstat -ano | findstr :<port number>
    For example:
    C:\Users\n>netstat -ano | findstr :2000
    You will see such message:
  2. last number is ID of process. To kill process:
    taskkill /pid <process ID> /F
    C:\Users\n>taskkill /pid 3560 /F
    SUCCESS: The process with PID 3560 has been terminated.


Posted in C language (en) | Leave a comment