Category Archives: Uncategorized

Docker fails to fetch http://deb.debian.org/debian/dists/buster/InRelease

I found a network issue when trying to build my docker image: the command `apt update` fails with the following error:

W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease
W: Failed to fetch http://security.debian.org/dists/buster/updates/InRelease
W: Failed to fetch http://deb.debian.org/debian/dists/buster/Release.gpg Temporary failure resolving ‘deb.debian.org’
W: Failed to fetch http://security.debian.org/dists/buster/updates/Release.gpg Temporary failure resolving ‘security.debian.org’
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/Release.gpg Temporary failure resolving ‘deb.debian.org’
W: Some index files failed to download. They have been ignored, or old ones used instead.

This happens because your ISP DNS servers are not reachable from this network. The easiest workaround is to directly instruct Docker to rely on some public DNS servers proven to be stable and reliable (Google, Cloudflare).

Add them to a new configuration file called daemon.json:

$ sudo pico /etc/docker/daemon.json

Insert the following:

{
    "dns": ["1.1.1.1", "8.8.8.8", "8.8.4.4"]
}

Then restart the service:

$ sudo service docker restart

Test Assignments

In recent years I have applied to numerous development jobs driven by my will to develop my career and find better pay. It’s common nowadays for companies to give test assignments supposed to verify the candidate’s coding skills, as well as his/her ability to organize work. There is no test assignment I have failed to fulfil, but there are many times when I failed to explain it properly in a technical interview discussing my solution. I am a self-taught developer and have no formal technical education (excluding the high school where I specialized in microprocessors – a more hardware-oriented field of study). So, when the technical interviewer says “Nice solution, but can you describe the cyclomatic complexity of it?” I am done.

Honestly, I am aware of my skills, strengths and weaknesses. I haven’t gained experience with a lot of modern and trendy technologies that well-paying companies require. What kept me in the game for 15 years is mostly my ability to troubleshoot complex problems and provide simple solutions to them. Additionally, I have excellent communication skills, and I can explain complex technical issues to non-technical stakeholders in a way that is easy to understand. This has proven valuable in many situations, where I have been able to build strong relationships with clients and stakeholders and ensure that everyone is on the same page. That’s why my recent employers trust me to mentor and onboard others, not because of my top-notch up-to-date experience with all the fancy new technologies that popped up recently.

Anyway. This post is a short review of what I’ve done as coding challenges in recent years. I hope it’s a pretty comprehensive code base proving my ability to solve problems with code. Honestly, if I have to write yet another code assignment, I feel better working on something else and fuck development.

Continue reading

Accessing Samba on Manjaro: failed to retrieve share list from server

A few days ago I got my shiny new StarBook Mk V and installed Manjaro on it for the very first time. I have no prior experience neither with Arch-based distros not rolling releases. Anyway, soon after I installed it I realized that I can’t access my homemade NAS server over Samba. I have a samba network at home with a mix of Linux (Linux Mint, Manjaro) and Windows 10 (don’t judge me) computers. Samba has always worked well to connect to each other. But now, when opening smb://192.168.1.6 in Gnome file manager I get this error: Failed to retrieve share list from server: Invalid argument

After quick duckling I found the solution: everything you need to do is to add these two lines in the global section of /etc/samba/smb.conf file on the server

client min protocol = CORE
server min protocol = CORE

and then restart it:

sudo service smbd restart

Voila!

P.S. The solution is based on the original post on the Manjaro forums here.

My favorite programming quotes

“90% of coding is debugging. The other 10% is writing bugs”
Bram Cohen (the author of the peer-to-peer BitTorrent protocol)

“The programmer who refuses to keep exploring will surely stagnate, forget his joy, lose the will to program (and become a manager).”
Marijn Haverbeke

“The more I learn, the more I realize
how much I don’t know.”
Albert Einstein

“Never memorize something that
you can look up.”
Albert Einstein

Add GIT branch information to Bash prompt

I’ve seen such as fancy Bash prompts on various tutorials and Linux examples over the Internet and I’ve always wondered how is achieved. I never really had a enough free time to learn more about it and explore the options. But being jobless for a month gave me opportunity to play with the thinks I like 🙂

My solution is pretty simple: when you navigate to git controlled folder, the bash prompt will show “@ branch” after the directory name. Nothing fancy.

Just open your ~/.bashrc configuration file with your favorite editor and add the following:

get_git_branch () {
git name-rev HEAD 2> /dev/null | sed "s/[a-zA-Z0-9]\+\ \(.*\)/ @ \1/"
}

than put this into your PS1 string:

$(get_git_branch)

so it become something like that

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w$(parse_git_branch) \n\$\[\033[00m\] '

Restart your terminal or type bash to start new bash session. Navigate to git controlled folder to test. It should look like this:

bash-git

Generate huge JSON files with custom PHP >5.3 class

Lately, I’ve been working on transitioning XML feeds to JSON format on big video site.  We generate these feeds in order to feed external search service with results. It’s similar to sitemap, but it provides more detailed information about the pages.

This task is challenging because of the following problems that need to be resolved:

  1. The feed need to represent over 500 000 database entries i.e. videos. It’s just not possible to generate huge PHP multidimensional array with more than 500 000 elements and pass it to json_encode(). Obviously, you need to generate small JSON objects (chunks) concatenated with hand-coded strings and so build the full feed.
  2. The development and production servers we use are equipped with outdated PHP version 5.3.27. That means:
    – No meaningful error messages because json_last_error_msg() function it’s not available prior PHP 5.5
    – No JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, and JSON_UNESCAPED_UNICODE
  3. The code should be easy to test and maintain, so it should provide meaningful debug information and error handling.

Continue reading