NET USE GUI to mount a network drive on Windows

The gui

This is more a SysAdmin tip. If you are on customer service, or if you need to have an app-type network drive mounting solution, the NET USE GUI is what you are looking for. Here you can download the app from SourceForge. The zip contains an executable, so no need to download anything else. It’s ready to use.

Why you may want an app instead of Map Network Drive? Allow me to explain. Inside a corporative network, there’s no need to know your domain. But this app will only map the drive if ALL the fields are correct, that is, the server, the share, the username, the password and the domain. On the other hand, when mapping the network drive, a lot of options are available, one of them, the user, being specially tricky, at least in my case. My people were complaining about the drive not mapping: the reason was just the way the username was written: is’s not so obvious to force the user to write the domain name before the name to successfully map it. That’s it: your name can be username but never DOMAIN\username. That is simply wrong. This app will forever free you from the issue, thanks to the specific field. At least in my case πŸ˜‰…

Not a post

It’s funny that I was thinking about posting once per day and ended up not posting at all. What have I’ve been doing the last days? Playing with the layout of the blog, ordering my digital life, cleaning up my code. Crying aloud about that I’m not yet vaccinated. Working, procrastinating. Checking Amazon, doubting about if to buy a new gadget that I don’t need. Also, I had a serious ear infection that messed up my equilibrium. Therefore I was groggy most of the time. Now it’s gone. Yeah. I was definitely living, so to say. I hope to come back from this interlude soon. This is a first step to break the curse of the white space, the curse of the writer. See you soon, then.

C++ interaction with database

I’m sorry but my muse seems to be missing again. And my dreams, although interesting, are not clear enough to write about them. So how about in the meantime learning a little bit more of C++? For example, have you ever wonder how it is possible to record the output of your C++ data into a database? Before we start, let me just say that I don’t think mixing up languages is a good idea. If you know mysql is for databases, python is for data, and C++ is for…objects, why don’t you write a pipeline from one to the other, instead of a language salad? So you don’t need to be an expert on everything, just on the component you handle. Anyway, here’s what I found.

The best tutorial that worked out of the box is this one of tutorialpoint. With small examples, you will learn that to handle a database you need first to connect to the database, then you need to create a table. After that, you must insert some data, that you can select afterwards if you want to print it or something. All of the examples worked on my test machine with CentOS 7.X, and mariadb up and running. Do I recommend the method? I’m not so sure. If you are a hardcore C++ you may need it (if you are a hardcore C++ you should not read this) but the code given is completely safe, with error messages and so on, so I will reccommend it. It is all thanks to #include sqlite3.h functions like sqlite3_open and sqlite3_exec that can be explained by themselves.

If you are a windows user (and a C++ user) you may find this other link from geekforgeeks of use. Now there they use another include, #include <SQLAPI.h> that is giving to the sample code a completely different feeling. More sql-oriented, if I can call it like that.

To finish with the tour you have this example from codeguru. Here you see the third player of this game, the #include <mysql.h>. I find this one quite complete, with a C++ class. I didn’t try it, but this is not meaning I can’t comment on it. The functions interfacing with the database are here mysql_real_connect, mysql_use_result, and similar that will also explain themselves by name.

Time to choose. Which one to play with? Do you have a choice? πŸ˜‚πŸ˜‚πŸ˜‚. Yes. You can do it with python…but I will leave that for the next post. Old school I am πŸ˜‰.

C++ check if an entry exist in a file

I think you know already how to write and read from a file in C++. If not, you can check my previous post C++ data acquisition. I’m trying to produce a CSV (comma separated values) file where I make an entry per username and date. Since I don’t want to end up with an enormeous file, I want to check if the user username has already an entry. How do we do that? The best solution I found on this Codeproject post. This is my version of it.

//generalrecord is a string with the name of the file
ifstream ifs(generalrecord.c_str());
string word = c_username; //our username
string line;
bool is_there = 0;
while( getline(ifs,line)){
size_t pos = line.find(word);
if ( pos != string::npos){
cout << " WARNING: found previous record " << endl;
is_there =1;

ofstream cou(generalrecord.c_str(),std::ios_base::app);
if(!cou) {
cout << " Cannot open general record file.\n";
if (is_there ==0 ){
cou << c_username << data1 << data2 << endl;

Note that I use two “streams”, one to search for the entry, the other to record the entry, and that I record on “cou” (do not mix it with “cout”) only if there is no previous entry. In principle more safety checks can be included, like how old is the entry, etc. But I let that exercise to the reader πŸ˜‰. The problem is, you never end up coding, specially if you are alone. Anyway. Have a nice weekend, “if possible” (a programmers pun) 😁😁😁.

Locate your desktop background on macOS

It was weird for me that I was still having a certain background picture even after moving from iCloud it to my permanent photo storage. Then I realised that I don’t really know where macOS stores those pictures anymore. I mean, to add a background is easy, but after that where is the picture going?

There are a couple of places you can look at. One of them is the Library Cache. On a clean desktop, open the Finder folder and select menu Go -> Go to Folder or use the shortcut Shift + Command + G to access to /System/Library/Cache/Desktop Pictures. There you have the default ones, like the one above. My phantom picture is not there, so I go to the next location, /Library/Cache. I’m not sure if this is a different cache, but there it was my file, stored under a somehow random name. If you want to know more, check the StackExchange post about.

In order to find somehow a permanent solution (have we something permanent nowadays?) we can ask our OS to print the desktop picture path like displayed above (original post here). In a nutshell:

$ > cd /Applications/Utilities/
/Applications/Utilities $ > defaults write
desktop-picture-show-debug-text -bool TRUE;killall Dock

And to remove it:

/Applications/Utilities $ > defaults delete
desktop-picture-show-debug-text;killall Dock

I hope not to have anymore a phantom background now that I’ve made a post about it. 😁😁.

Bash : get text from stdout and store it in different files after the selection

Oh my gosh! I’ve been looking for this one for more time than I should have. Let’s say you are reading a very big file, log file or similar. In my case, it’s a compressed file, so I read it with bzcat. Let’s say you know you want to chop the output into small parts, depending on field number 7, for example, and store everything matching field 7 onto the same file. That means producing as many files as different field 7 values. How do you do it with one line? Like this:

Β bzcat mylogs.bz2 | awk -F ":" '{ print $0 
> "output_"$7".txt" }'

So I pipe everything I read from mylogs.bz2 to an awk that uses the field separator : then dump the read line ($0) onto different files named after the field $7 (username in my case). For example everything named “pepito” will end up on a file called “output_pepito.txt”.

I have some deja vu. Maybe I wrote about this already? Check my awk crash course, and filtering data with awk if you don’t know what I’m speaking about here. And learn to love awk, not the shell. Or not C++, because this trick saved me literally hours of processing time. See you on the other side! ❀️❀️

Avoid typing ssh passwords with sshpass on macOS

Again this is a tool that I thought I never needed. But I’m still working at home and I’m getting tired of typing the password each time I have a network connection issue. One second lost is not a lot, but that accumulated over the days can become minutes, specially if you work on different machines and you mistype because of an already hard butterfly keyboard on your MacBook Pro. We can (of course?) script ssh logins with password on Linux with sshpass, so I’ve decided to try the same on my macOS Big Sur 11.4. I have installed brew and I’m ready to use it. Let’s try it out.

user@macbookΒ  ~ $ > brew install sshpass
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "sshpass".
We won't add sshpass because it makes it too easy
for novice SSH users to

ruin SSH's security.

What a nice guys, caring for my security. Of course we should care. Let’s google it a little. This StackOverflow post suggests to use an unofficial brew. I’m unofficial also, so I try the first one. Unfortunately it doesn’t work. My error reads:

`brew extract` or `brew create` and `brew tap-new` to create 
a formula file in a tap on GitHub instead.:
Invalid usage: Non-checksummed download of sshpass
formula file from an arbitrary URL is unsupported! (UsageError)

Scary. Specially if we consider what we are trying to install. What if we end up installing some kind of password sniffer instead of our tool? Security is not my main field, but this is not meaning I don’t care about. Anyhow. Next brew formula does seems to do the job. This is my output:

user@macbook ~ $ > brew install hudochenkov/sshpass/sshpass
==> Tapping hudochenkov/sshpass
Cloning into
remote: Enumerating objects: 14, done.
remote: Total 14 (delta 0), reused 0 (delta 0), pack-reused 14
Receiving objects: 100% (14/14), done.
Resolving deltas: 100% (3/3), done.
Tapped 1 formula (14 files, 9.2KB).
==> Installing sshpass from hudochenkov/sshpass
==> Downloading
==> Downloading from
######################################### 100.0%
==> ./configure --prefix=/usr/local/Cellar/sshpass/1.06
==> make install
🍺 /usr/local/Cellar/sshpass/1.06: 8 files,
78KB, built in 34 seconds

Now what? Do we have it? It looks like. To end it up, I build a small script “connect_to” per each machine I want to connect. A sample one will look like this:

export SSHPASS='MY-very-SECRET-password'
sshpass -e ssh -Y

We save it, do chmod 777 and test it. There you have it. Better, right? 😊

Exposing your local web to the internet with ngrok

One can do multiple things with ngrok. You can use it to generate public ssh access to your raspberry pi, or one command for an instant, secure URL to your localhost server through any NAT or firewall. We are going to try the last one.

First step is to open an account. The account creation is needed, and I’m fine with it, since all the features are given after connecting them with your account. I’m going to try to expose the web I have on my linux server. The zip I download includes a binary only. If I run it on the place I’ve unzipped it, this is my output.

ngrok - tunnel local ports to public URLs and inspect traffic

ngrok exposes local networked services behinds NATs
and firewalls to the public internet over a secure tunnel.
Share local websites, build/test webhook consumers and
self-host personal services.
Detailed help for each command is available with
'ngrok help <command>'.
Open http://localhost:4040 for ngrok's
web interface to inspect traffic.

ngrok http 80 # secure public URL for port 80 web server
ngrok http -subdomain=baz 8080 # port 8080 available at
ngrok http # tunnel to host:port instead of localhost
ngrok http https://localhost # expose a local https server
ngrok tcp 22 # tunnel arbitrary TCP traffic to port 22
ngrok tls 443 # TLS traffic for to port 443
ngrok start foo bar baz # start tunnels from
# the configuration file


inconshreveable - <>

authtoken save authtoken to configuration file
credits prints author and licensing information
http start an HTTP tunnel
start start tunnels by name from the configuration file
tcp start a TCP tunnel
tls start a TLS tunnel
update update ngrok to the latest version
version print the version string
help Shows a list of commands or help for one command

So it’s coming with a decent documentation. Once I’m logged in with my account, I copy what suggested (token included). Something like this:

./ngrok authtoken SoM3verYLArgeCHAinOfLett_er5_AND_NUmbers
Authtoken saved to configuration file: /root/.ngrok2/ngrok.yml

I can now try it out. I want to see “from outside” my web, so I do

./ngrok http https://localhost

My Terminal becomes this:

ngrok by @inconshreveable (Ctrl+C to quit)

Session Status online
Account My Name (Plan: Free)
Version 2.3.40
Region United States (us)
Web Interface
Forwarding -> https://localhost:443
Forwarding -> https://localhost:443

Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00

I go then to my “external” computer and type Eureka! I see my page. If I do CTRL+C on my Terminal, the web is no more visible. On its place is shown the message

Tunnel not found.

I try starting it again ./ngrok http https://localhost but I get ANOTHER “something random” URL which is good, I believe, since I want to use this on an emergency. If I want a permanent URL (that is this “SomeThingRand0m”) we need to pay. And you know I can’t spend public money on these toy projects 😁😁.

If I’m more concerned about the security, be aware you can password-protect your tunnel. Actually it’s quite simple, just add after http -auth=”username:password” and you get it. I have forwarded a kerberos-protected folder, I was asked to give my kerberos ID, that I filled, and it worked. All in my sandbox, of course. But definitely a very nice tool. Anyway be careful with these things, you never know who’s monitoring!

Dry land

“I’m having trouble getting my phone fixed but I’m going back in a bit and then we are just waiting on you guys.” She texted.

“If she doesn’t have a phone, how the hell she sent the message?” Christoph was reluctant from the very beginning about the idea of letting her go alone to the shop. We were scheduled to come back in less than three hours. The phones, the same than everything else we were carrying over, was supposed to end up being just an atomic cloud afterwards.

“Don’t know, doesn’t the shop give you a replacement while your phone is being serviced?” Alena tended always to cover her friend. She and Christoph were together since our first trip, which is funny, since she originally declared her love for Joe.

“Maybe. She wants us to go directly. Shall we start?” I gently pushed them into the car. I learned to love to drive after my first trip, so I took the pilot seat. Christoph and Alena sit together in the back. I started the engine and carefully left the parking place.

“I’m not surprised they were almost extinct.” Said Alena suddenly. “I don’t understand what do you see on driving an auto. They are burning liquid bones and plants, for the sake of God.”

“Well, you must admit, Alena, that this place has its charm. With all the …macroscopic technology and colourful food. I remember you face when you tried that pizza. I will not believe you if you tell me you didn’t really enjoy it!” I turned to the left. The traffic was quite relaxed, very good. We had plenty of time to reach the cinema, but I wanted to find a nice spot to park and buy popcorn and beer before entering. I wanted the whole experience. “And you, Christoph, don’t you like this?”

“I do like it. Specially the beer. It makes my heart tinkles!” He smiled widely. “Anyway, you guys know, everything else is better than that dry land.” Alena used the moment to hug him. They were really sad to leave, it was all visible around their round faces. On our first trip together, they almost did not interact with anything, now they were even eating local food. “But I do also understand our terms and conditions. I’m making my mind already for the transition. It’s helping me to land back.”

“Yes, it’s better that way for me also.” I added. “Besides, this doesn’t need to be our last trip. It’s going to take me a little, but I do plan to save enough for another trip.How about you guys?”

“Yes, definitely. We’ll love to join you, as before.” I parked the car and we went to pick them up.

Tuesday Morning dream

I think these pieces may serve to perform some kind of autopsy of my mind state in the future. Allow me to explain. I got two nephews, twins, that unfortunately I didn’t meet yet because I was not sure (or not allowed) to travel to their city. Now that the crisis looks like it’s about to end, I start again to consider paying a visit to my sister. I don’t think it’s going to happen until I have some kind of certification of being inoculated, but this is not stopping my mind to wander about, specially during my sleep.

So in my dream there I am, landing on my motherland after almost two years. Of course the world was still spinning during my absence, and what was supposed to happen, happened. I feel the new normality is not different from the old one, in any case, people go out earlier and bars and cafes are more populated than before. Touristic areas have another feeling that I will call ancient, since all the travellers look all from around, not from another continent.

The meeting with the family will be on a big mall, close to a recovered area of the city. One of the godfathers, probably the ex-general, has booked one big party room that should not be difficult to find. It’s a new trend, apparently. This way, you know for sure who was there, in case of contagion. The promise is of a place with children toys, as well as bar, catering, and live music. I arrive early, so I stop by on a cafe on a bifurcation just to observe the people passing by. Suddenly someone taps on my shoulder and says my name. One of my friends from my youth. I’m following him on the social networks, so I’m not surprised of how he looks. He tells me he’s there to meet a couple of friends from his band, and he insists he needs to introduce them to me. Not very convinced about, I gulp my beer and I follow him. We take a service corridor that ends up on a backyard, the opposite to the facade of the mall. There is barely a path between what looks like plied-up discarded containers, construction tests -I mean broken concrete pieces, or ruins of the old building- and gravel mounts. I hesitate, but he keeps pushing me through the war zone.

Just to end up on another back door of the same mall. There his friends, fully geared with musical instruments, are waiting for his lead guitar. My friend introduces them to me, then we enter the building through a service corridor that ends on… the place the ex-general hired. They were the courtesy band of my big family reunion.