Archive for February, 2020

[ C lang] reading a text file line by line

February 22, 2020 Leave a comment

I had a text file that I was reading line by line in C. Every line was tokenized. The file looked like this:

1978	Aachen Cathedral	DE	C	EUR	0	3
1978	City of Quito	EC	C	LAC	70	2
1978	Galápagos Islands	EC	N	LAC	14066514	1

I converted every year to an integer. From the 2nd line I got 1978 (as int), but in the first line the string to int conversion failed.

It turned out that the token “1978” in the first line was 7 characters long, not 4. At that point I opened the file in a hex editor and there were 3 special bytes at the beginning: EF BB BF. This is a byte order mark (BOM).


As a quick fix, I removed those 3 bytes in the hex editor.

I tried it under Python too and it caused a problem there too:

>>> f = open("input.txt")
>>> s = f.readline()
>>> s
'\ufeff1978\tAachen Cathedral\tDE\tC\tEUR\t0\t3\n'
>>> s.split()
['\ufeff1978', 'Aachen', 'Cathedral', 'DE', 'C', 'EUR', '0', '3']
>>> s.split()[0]
>>> int(s.split()[0])
Traceback (most recent call last):
  File "", line 1, in
ValueError: invalid literal for int() with base 10: '\ufeff1978'

If you know how to ignore those bytes during file read, please leave a comment. I’m interested in both C and Python solutions.

[windows 10] Display accented characters correctly in the terminal

February 22, 2020 Leave a comment

Under Windows 10, in the terminal (cmd), accented characters are not displayed correctly. How to solve this problem?

In Windows 10 (build 1809) go to the system’s Language settings, select Administrative language settings, click on Change system locale… and check the Beta: Use Unicode UTF-8 for worldwide language support box and then restart Windows.

(In Hungarian Windows: Gépház, Idő és nyelv, Nyelv, Felügyeleti nyelvi beállítások (jobb oldalt), Területi beállítások módosítása…, Béta: … bekapcsolása).

Categories: windows 10 Tags: , , ,

Use Your SSH Server as a Proxy

February 14, 2020 Leave a comment

See . The section entitled “Dynamic Port Forwarding: Use Your SSH Server as a Proxy” did the trick for me.

Categories: network Tags: ,

How to sync my Visual Studio Code settings using Dropbox?

February 13, 2020 Leave a comment

You set up your VS Code, spend half a day with your settings / extensions / snippets, and you want to use the same settings across all your machines (including Linux and Windows boxes too). How to do it?

First, let’s see where your settings are located.


Location of your settings: ~/.config/Code/User . The important entries are:

  • settings.json
  • keybindings.json
  • snippets/ (directory)

Location of your extensions: ~/.vscode/extensions .


Location of your settings: C:\Users\username\AppData\Roaming\Code\User (on Windows 10). The important entries are the same:

  • settings.json
  • keybindings.json
  • snippets/ (directory)

Location of your extensions: C:\Users\username\.vscode\extensions (on Windows 10).


To share your settings, create a folder in your Dropbox folder and move there the files settings.json, keybindings.json, and the folder snippets/ .

Then go to your local User folder and put symbolic links on the three entries that you just put in Dropbox.

Don’t store the extensions in Dropbox! Sometimes they install binary files that are different under Windows and Linux. Simply install the extensions locally on all your machines.

To get a list of your extensions, run the command “code --list-extensions” in the terminal.

How to create symbolic links under Windows?
Open a terminal window in administrator mode. Then,

# symbolic link on a file:
mklink Link Target

# symbolic link on a directory:
mklink /d Link Target

How to sync my Sublime Text 3 settings using Dropbox?

February 11, 2020 Leave a comment

You re-install a Linux machine and you want to use your Sublime Text 3 editor settings on this machine too. How to sync your complicated settings?

The answer is here: link.

To properly sync your installed packages across different machines, you actually do not want to sync the whole Packages/ and Installed Packages/ folders. The reason for this is that some packages have different versions for different operating systems. By syncing the actual package contents across operating systems, you will possibly run into broken packages.

To sync the folder, you generally move Packages/User/ into your Dropbox and create a symlink to it from Sublime Text 3/Packages/.
” (source)

screen zoom

February 11, 2020 Leave a comment

I wanted to enable screen zoom. It’s very handy for presentations.

Under Manjaro, it worked out of the box with Alt + mouse wheel.

For Ubuntu, I found a video that presents a solution based on Compiz (see here). Unfortunately it didn’t work for me. It turned out that Ubuntu 18.04 uses Gnome Shell, which is not compatible with Compiz.

However, there’s a way to make it work under Gnome Shell, see the video here.

In short:

  • open Settings; on the left Devices -> Keyboard. Scroll down to “Universal Access” and assign key combinations to 1) turn zoom on or off, 2) zoom in, and 3) zoom out. I assigned Super+Alt+*, Super+Alt++, and Super+Alt+, respectively.
  • Go back to the main menu of Settings and select Universal Access on the left. Click on Zoom. Enable it (ON), set magnification to 1.00, and I chose “follow mouse cursor”.
  • CLose the Zoom settings window. At the top, enable “always show universal access menu” (ON).

Now you can zoom in and out with Super+Alt++ and Super+Alt+, respectively.

Categories: manjaro, ubuntu Tags: , ,

Dropbox is stuck at syncing

February 11, 2020 Leave a comment

Under Ubuntu 18.04, my Dropbox client stopped working. I have a big Dropbox folder and it synced at least 90% of it. But then, it simply indicated “Syncing…” and nothing happened. I left it like that for a night but next morning it was still “Syncing…”. What da hell?

I stopped the client and launched it from the command-line:

$ cd ~/.dropbox-dist/
$ ./dropboxd &

And luckily it dropped an error message on the screen:

Unable to monitor entire Dropbox folder hierarchy. Please run "echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p" and restart Dropbox to fix the problem.

So that’s it. This Ubuntu box of mine was freshly installed and the default settings were not good for Dropbox. After executing the proposed command, Dropbox started to work normally.

Thus, the command to issue is:

echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p
Categories: linux, ubuntu Tags: , ,