Progger of 21th centure: editor
Git: How to Prevent a Repository Branch from Being Published
Sometimes, you need to keep a branch private, and to protect yourself from accidentally clicking ‘Publish Branch,’ it’s a good idea to prevent its publication. On Windows, you can do it like this…
In the folder .git/hooks
, create a file named pre-push
(without an extension) and place the following content inside:
#!/bin/sh # List of branches to protect PROTECTED_BRANCHES="local-branch-name" # Get the name of the branch being pushed current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/,,') # Check if the current branch is in the list of protected branches if echo "$PROTECTED_BRANCHES" | grep -w "$current_branch" > /dev/null; then echo "Pushing to branch '$current_branch' is not allowed." exit 1 fi
[Solution] VLC Off Screen (window not visible)
The article was updated in 2024 to fix this issue once and for all
ARRRGGH! For several years, the same issue persists—VLC player keeps disappearing off the screen. I always forget how to retrieve it and end up Googling. Here’s a quick guide on how to do it:
- Open VLC and make it “active” (click on it from the taskbar) so it becomes the currently selected application (even if you can’t see it).
- Put aside your mouse, you won’t need it 🙂 Press the Alt + Space keys.
- A small popup menu should appear on the side of the screen. Look for the “Move” option (if it’s not there, use “restore”). Select it.
- Now use the arrow keys to “pull” the player back from the edge of the screen. My VLC always slips to the left, so I use the left arrow. When you’re done, press Enter.
If this doesn’t help, you might just need to reinstall the program.
Next… Here’s how to prevent this from happening again (this occurs to me with low DPI and 4K video):
“Select which icons appear on the taskbar” setting is missing
For a dozen years, Windows has had a setting – “what to display in the tray”. It’s called: “Select which icons appear on the taskbar“. And now in Windows 11, it’s gone. WHAT TO DO?
No need to panic. Billy has “improved” our life once again. I already went into
HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify
to pull out the hexadecimal values of the apocalypse… by the way, here’s a script… note that you need to have the app you want already opened in the tray to extract its ID:
# Export the TrayNotify key $regPath = "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" $exportPath = "C:\path\to\output\TrayNotifyBackup.reg" Reg export $regPath $exportPath Write-Output "TrayNotify key exported to $exportPath"
And then you need to insert this ID:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify] "YourAppIdentifier"=dword:00000002
But… it TURNED OUT, that Billy kind of made a convenient thing. You can DRAG icons from hidden to the active tray WITH A MOUSE. @#$%in mouse. And why couldn’t they write about this in the place where this setting was removed?
I apologize for the tone, but when you’re dealing with Billy – it’s hard to write any other way.
Windows server via RDP: problem with resolution and DPI
When you connect via RDP to a server on Windows, Windows automatically selects the resolution and DPI based on what is set on the client.
That is, RDP “mirrors” the client. And if you connect from a machine with high DPI, then RDP will set a high DPI on the server too. Which can interfere with installing some apps (for example).
Moreover, if you simply change the DPI on the client – it will not help immediately. You need to reboot the client, and then reboot the server. Then everything will be mirrored correctly. Well.. that’s essentially what this article is about. You need to change both and.. reboot here and there. Billy the Pervert surprises as usual.
There is also another option:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\IgnoreClientDesktopScaleFactor
DWORD32
Value: 1
Disable Go language telemetry
It turns out, Go (specifically gopls aka the local language server) collects telemetry, the scoundrel. Gathering some kind of anonymous data on how we code. How to disable it:
- C:\Users<user>\AppData\Roaming\go\telemetry
- create a file there named
mode
(without an extension!) - inside the file, write just one word:
off
Although, in terms of Windows telemetry, I gave up a long time ago – got tired of cleaning it up. But if there is some sort of tele-perversion that can simply be turned off once and for all – it must be done. Just so PC won’t slow down in vein.
Architecture in programming
In programming, as in construction (and everywhere else – from shearing sheeps to hammering nails), the foundation of everything is architecture. It determines the stability and functionality of the final product. Let’s consider this process through an analogy with building a house, reflecting different levels of developers’ experience: from a shack to a stone house. Continue reading
[Windows] Remove different “types” of folders in Explorer
The worst thing in Windows is the display of media file details in file explorer. Billy’s explorer likes to impose on users the type of folder (music, photos, etc.) they supposedly “need”. Changes in folder type settings are gliching. To remove this heresy abomination once and for all:
REG ADD "HKCU\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell" /V FolderType /T REG_SZ /D NotSpecified /F
Thank you for your attention.
Prototypes – key to success in programming
If you are developing a complex (solo) project with many components, do not try to fully implement all these components at once. Make stub prototypes. This will save your stamina and prevent you from burning out on the project early.
Also use paper. LOTS OF PAPER. Make tables and diagrams, draw with pens and pencils. This will help you write good code.
Turn Windows 11 into Windows 10 (UI)
It turns out that I forgot to share this thing, which I’ve been using for a long time…
ExplorerPatcher – allows you to rollback some elements of the terrible interface of Windows 11 to the normal classic period of ten or even seven: return the classic “Start”; adjust the taskbar, tray, explorer; remove all the idiotic features and add back useful 🙂
The link above goes to a githab, download from the releases, put it on. Then to run it, RMB click on the taskbar -> “Properties”:
I have been using version 22621.608.51.1
for a long time; it works fine. When upgrading the Windows, nothing flies off. Recently I’ve updated ExplorerPatcher itself (I’ve never done it before); works like a charm 🙂
Go language. About runes (data type), PostgreSQL and JS
If you are making a Go network application that works with databases and/or javascript, you need to be careful when using the rune data type.
For example, PostgreSQL does not have a data type that matches rune; There are options for storing rune:
- store in
CHAR(1)
– then you will need to convert every time you unload from the database like this:[]rune(symbolStr)[0]
- store in
BYTEA
; unload via w….make([]byte, 4)
- or a slightly less obvious variant – store in the database as
INT
; which is the most relevant.
Plus… Javascript can’t handle runes either. I have to render the output like this: String.fromCharCode(.Icon)
;
By the way… It’s funny, not all emoji (unicode characters like ) can be stored in rune. Because some of them exceed the size of rune, because they use an extra Unicode selector:
- “🏘️” houses (U+1F3D8 U+FE0F)
- “⛰️” mountain (U+26F0 U+FE0F)
- “🏔️” mountain with snow (U+1F3D4 U+FE0F)
And it’s not just emoji, but just some basic Unicode characters.
So you have to be careful with rune.
VS Code – custom hotkeys for terminal
I got addicted to VS Code. I’ve fallen in love with this little bastard from Microhard. It’s convenient for Go, nothing to do with it… And for this very Go, you need to constantly loop with the console to run the project via go run .
Doing it every time by hand is, of course, unkosher. So here’s what we do, Mikhalych:
-
Ctrl+Shift+p
Preferences: Open keyboard shortcuts
- click on icon in the right top corner
Open keyboards shortcuts (JSON)
- add there:
Feedback on the CS50 programming course
Postgresql – newbie problems
1) Requires password all the time when starting pgAdmin 4
(which is irrelevant for localhost)
Solution:
go to C:\Program Files\PostgreSQL\15\pgAdmin 4\web\
make a copy of the file config.py
call it config_local.py
Change MASTER_PASSWORD_REQUIRED
to False
2) By setting the bin folder to PATH, you can call from the terminal
psql
but get error: psql: error: connection to server at “localhost” (::1), port 5432 failed: FATAL: password authentication failed for user “vasya”
Solution:
run from regular user psql -U postgres
Golang. Sum of consecutive numbers
The problem is to find in an array of integers a sequence of consecutive numbers whose sum is equal to n.
Our program will read a list of integers (e.g., 5 2 3 4 6 1 4 10 1), followed by one integer n (e.g., 7). Example output:
5 2 3 4 6 1 4 10 1
7
5 + 2 = 7
3 + 4 = 7
6 + 1 = 7
Go Language. Map Exercise
Based on the list of dungeon raids, find the top player in the guild 🙂
Example of input:
Golang. Exercises for slices
Let’s look at some examples of slice programs in Go.
First one… The user enters two rows of numbers. Our task is to collect them in one slice, removing duplicates. As an exercise, we will not use cards, but ordinary slices.
Code: