Extend Ubuntu 18.04 LTS updates?

How do I extend updates for my Ubuntu 18.04 LTS? I don’t want to reinstall a new one.

ANSWER

Yes, Ubuntu LTS versions have a standard support period of only 5 years. The 18.04 will have that on April 2023. Coming very soon.

If you are not yet ready to install a new one, but still get the official updates from Ubuntu, then you can sign up for Ubuntu Pro. Register here – https://ubuntu.com/pro.

How to do that? Follow the guide here – https://ubuntu.com/pro/tutorial.

Once you have signed up and enabled Extended Security Maintenance, or ESM, then you are good for another 5 years of security updates. That will end on April 2028. A long way off, but plenty of time still.

Stress on the word security. It doesn’t mean you will get the newest versions of software installed on your computer for the next several years. That’s different. An alternative is to install the Snap version of a software to get the latest that the package maintainer offers. And if you don’t fancy Ubuntu Snaps, there may be Flatpak or AppImage versions of the same software.

Another way to type into Android Auto apart from default keyboard

Is there a different means to type in the search terms, song titles, or Map directions in my car’s Android Auto without having to use the on-screen keyboard?

The screen position and angle makes it so awkward for me to do so.

ANSWER

One can always use the Google Assistant via voice commands when interacting with Android Auto in your car, especially when actually driving, for safety reasons. I would say this option is recommended as it’s faster and hands-free, even when parked or at a stop light.

Yet, there are valid reasons to have to type in something into Android Auto via its on-screen keyboard other than voice.

Aside from the reason in the question above, the car’s touchscreen might be laggy. The keyboard layout could be not so friendly (such as screen size). Then there’s also that thing where one isn’t sure how to say a word or address, and Google just wouldn’t understand your accent, too (this happens for non-native English speakers).

The very simple alternative would be to use your phone’s keyboard. Yes, this can be done easily.

If one hasn’t noticed, there is an icon on Android Auto’s keyboard that is shaped like an upright rectangle with an arrow in it that should be pointing to the right. Tap that key, and the keyboard of the phone it is attached to will open up, where then you can type in comfortably what you need to write. Make sure the phone is unlocked. To make it easier, there’s also a setting on Android to allow it to be automatically unlocked when this instance happens.

Remember to always play it safe. Don’t do this when your vehicle is running. Stop and park somewhere if you have to, before taking your attention away from the road.

Compress all files in a directory separately via command line

How to do this fast and easily? I don’t care about what type of compression was used.

When I say compress I am referring to using a tool such as ZIP to make a file smaller. Separately – that is each file will have its own zipped file, instead of all being bundled into one big one.

ANSWER

On a Linux shell, such as Bash, I can do this command to zip up all the files in a directory individually.

find . -type f -exec zip -D '{}.zip' '{}' \;

The find command allows for finding many things. Here we specify where to look for it through that dot right after the command. Dot means the current directory location. Then the -type f tells it to find only those considered as regular files. Followed by the -exec zip so that when it finds those files it will do a zip on each one. The curly brackets is so that filenames are retained, then appended with a .zip file extension at the end.

Find is recursive. So it will also go down to subdirectories and zip any files in there, and so on. It can be prevented. One way is to use -maxdepth option. If I want it to not recurse deeper I tell it to have a max depth of 1.

find . -maxdepth 1 -type f -exec zip -D '{}.zip' '{}' \;

There are other ways – such as using a for loop on bash – but I’ve always been more comfortable with doing this through the find command.

Then there is also the gzip compression tool. This is another one similar to zip. Gzip command is much simpler and shorter.

gzip *

The * is a wildcard that matches any of the files that are in that current directory. It will ignore directories, so any files in subdirectories will not get compressed. Note that this short command deletes the original file once it’s been compressed. If I want to keep these files, I would put the -k option (long form is --keep).

gzip -k *

These commands will work on perhaps majority of Linux distros, assuming the zip and gzip applications are installed. It will also work on Bash-like shells for Windows. Better yet, Windows 10 has the Windows Subsystem for Linux feature.

Screen record to gif on Linux

I would like to record my desktop screen. Maybe a portion of it not the entirety of the screen. Then convert that into an animated GIF image. Would like to use less or none at all on image editing software where possible. What are the tools I will use in a Linux desktop?

ANSWER

My go to tools for this are Kazam and Gifcurry.

Kazam for screen recording my desktop. It is a simple tool. Has options to target fullscreen can include all screens, a window or an area on the desktop. The latter may be exactly what you need. The results are saved into a MP4 file.

Gifcurry can then load that video file, make edits, save it into animated gif.

I can also skip Gifcurry. Use ffmpeg directly instead. It can do a lot of things to handle video, audio, other media files and streams. But a simple command such as this one will do for starters:

ffmpeg -i video-file.mp4 -f gif output.gif

Get Around Disable Adblocker Pop-ups

I have adblocker plugins enabled on my mobile browsers. Which is great because a lot of websites have excessive ads and autoplaying media content that are so unnecessary. There are a number of sites that warn readers to disable adblockers, I have noticed however. Some have the option to continue without disabling adblockers. Many also don’t provide that option.

Is there a way I am able to get around disabling adblockers for such sites but still continue to view the content?

ANSWER

I’ve noticed that these pop-ups sometimes have different behaviors depending on the mobile browser being used. If one browser doesn’t have that option to continue to the site without disabling the adblocker, I try to open that same page on another browser. A few times I would get that option to not disable when shifting to another browser.

Another alternative which I more often do when I can’t be bothered opening the web page I want to read in another browser is to turn on reader mode. Most major browsers have that feature. Usually it’s a sqare-ish icon that looks like a document with horizontal lines, located at the address bar. If you can’t find it easily, try going to the browser’s options, then enable it. By simply tapping on this reader mode icon the disable adblocker warning will go away, and so do the ads. I can then proceed to read the page peacefully, less the clutter too. After all, I am only interested in the content, never the ads.

But if you frequent a website and like its content, consider supporting it by including the site’s URL as an exception to your adblocker settings. These ads support the site’s creators to continue providing people with content for free. If they have a subscription-based, ad-free offer, and it’s cheap-ish, why not spend a few pennies if you really enjoy their content? Some also offer non-recurring subscriptions through donations.

Filter Gmail messages quick

Getting lots of marketing emails in my inbox. Some might be worth taking a look at. But it is oh so cluttered.

How do I find emails from same sender in Gmail quickly?

ANSWER

Gmail’s search functionality is quite good. Lots of things you can do with it, almost like how you can on Google search.

For emails, search for a particular message via the email address by using this:

from:(email-add@example.com)

Replace the correct email address within the parentheses. If you want to look for more than one address at a time, separate email address with an OR (case sensitive). It will now look like this,

from:(email-add-111@example.com OR email-add-222@example.com)

If you don’t want to type the above, you do this instead. Open the message. Find the three vertical dots in the menu bar directly above the message. Click on it then select “Filter messages like these”. This will have the effect of that search phrase above less the typing.

Better yet, you can create a filter for these messages automatically if you take that step further. Apply a label to such messages for easier identification. Do something else about it if you will, such as delete, archive, etc.

As mentioned, when you open a message in Gmail, in the sub menu just above it, find the three vertical dots. This usually is located at the rightmost. Click on it then select “Filter messages like these”. Fill out the form as you like. The email address at the From line is the minimum. Proceed to create filter. Complete the form in the next page. It’s quite straightforward. I suggest you check at the “Also apply filter to matching conversations” at the bottom of the options. This will have the effect of filtering and applying what you want with the previous messages too.

And for some decluttering bonus, since I believe a lot of people get tons of emails without even reading them.

Now what if you have so many unread messages in your Inbox? You’d want to go through that and read/delete them, right? Well, it’s easy to search for unread emails on Gmail. Use this in the search box

is:unread in:inbox

Remove the in:inbox part to search for everything that is unread, not just in the Inbox. You can also replace that for another location on your Gmail.

You can combine this too with Gmail Labels. This is helpful if you tag incoming emails with Labels. This way you can set specific unread emails to search for and delete.

is:unread label:SOME_LABEL

If you don’t have those Labels, you can always create a filter and label emails from particular senders.

Windows “Sync now” failing

This is in the “Synchonize your clock” under the Date & Time settings of Windows 10. The button “Sync now” lets me update my date and time according to the time server that is time.windows.com. This fails for no apparent reason.

Error message I have is “Time synchronization failed” in red text on top of the button.

I’ve done this before successfully.

ANSWER

These are the things that you can do.

First thing is to check your Internet settings. The snc requires that you are connected.

Second, if you are using a firewall program other than the stock Windows one, be sure that it is not blocking with the sync server. Allow it in the firewall. Temporarily disablng it is another way if you don’t want to add another rule.

The default Windows firewall that comes in every Windows 10 should not be interfering with the sync. Check to make sure anyway by searching for Windows Defender Firewall from the Start Menu. Go to Advanced Settings link found at the left-hand side of the firewall window. The Windows time syncing is set on port 123 as UDP protocol that connects to time.windows.com.

Next, check on the time service. Hit Windows + R key combo. A small appears. Type after Open – services.msc – then press OK. This runs the Services tool and a window will appear after. There is a long list in alphabetical order. Scroll all the way down to the Windows Time service.

First off the service should be running. If not, check the Startup Type is Automatic. If not, correct that type so it should be so it starts automatically. Then proceed to Start the service. If it is already running, press the Stop button and wait for it to finish. Then Start it again shortly afterwards.

Check if time can be sync successfully now.

There are other things that can be done, such as pointing to another time server that is not controlled by Microsoft. I won’t normally do this, but it can be done with some extra steps in configuration which I won’t tackle here.

Google Search keeps saying “Mobile data is off”

I have Wifi and 4G data turned on but Google search returns with a message that says –
“Mobile data is off: No data connection. Consider turning on mobile data or turning on Wi-Fi”.

There is working Internet connection because I can search directly from the browser, other apps can connect or download. Only gets stuck with that message using Google Search app on Android.

ANSWER

When this happens, there are a few things that can help fix this issue.

First, is to restart the Android phone.

If restarting does not fix it, then the second thing is to turn on Airplane Mode. Wait a few seconds before turning it off.

However, if after doing either of the above, or both, that still doesn’t fix Google app from being able to connect to the Internet properly then the last resort is to clear its data and cache.

Go to Settings > Apps > Google.

What you need to look for is Storage related. There should be a Manage Storage > Clear All Data setting, and Clear Cache setting. These are separate buttons. Proceed by deleting cache first, then data. Clearing of cache and data only affects the device you are on. Google has most, if not all, of that information on their servers anyway. You won’t really lose anything. The app will sync back as soon as it’s connected.

Once done try using Google app again and search for something.

Should all else fail, reinstall the Google app. Chances are your Android won’t have permission to uninstall the app itself, only to rollback to previous versions, although there is an uninstall button in Google Play Store for said app. Do it anyway. Then update the app. If the phone is rooted, you just might be able to do a complete uninstall/install.

Install app latest version with Ubuntu Snap

I want to install application most recent version on Ubuntu. With this command snap refresh <app name>, but it doesn’t work.

Getting a ‘snap “<app name>” has no updates available’ message instead.

There is a higher version from snap info <app name> for example below.

channels:
  latest/stable:    12.5 2021-09-23 (50) 516MB classic
  latest/candidate: ↑                          
  latest/beta:      ↑                          
  latest/edge:      12.5 2021-09-19 (50) 516MB classic
  12.0/stable:      12.0 2020-06-12 (30) 462MB classic
  12.0/candidate:   ↑                          
  12.0/beta:        ↑                          
  12.0/edge:        ↑                          
  11.0/stable:      11.0 2019-09-04  (6) 399MB classic
  11.0/candidate:   ↑                          
  11.0/beta:        ↑                          
  11.0/edge:        ↑       

What I need do to force the update to latest version?

ANSWER

If you look at the “tracking” value after the snap info command, you will see the channel the app is currently on.

That’s the same channel listed in the “channels” information. To get that latest version you want, change the channel accordingly. Let us say you are at 12.0/stable now. You want to download and update to 12.5. That means you need to change to latest/stable channel in this case.

For that we will need to add an option that is --channel=<channel name> to change the target channel.

The command it will look like this in the terminal:

:~$ snap refresh <app name> --channel=latest/stable

This will immediately begin the download process to update to that version of that channel specified.

Add sudo optionally. Optional because Ubuntu will prompt you for your password if you don’t. A pop-up dialog window will appear for you to enter the password.

A way to stream Netflix in Nintendo Switch?

Is there a way to install custom app that can play Netflix on my Nintendo Switch, much like those unverified sources installation approach on Android?

I read there is easier way through “secret browser” to play Netflix. But many comments say it does nt work.

ANSWER

Short answer is – NO / None / Nada.

Unless, you install Android on or jailbreak it. The former means you’ll be technically booting to Android system. The latter is much more like what you probably have heard of people jailbreaking their iPhones, then run apps that were not supposed to be playable on the device.

Both are risky. It can cause irreversible damage to your Nintendo Switch. And you’ll end up with what they popularly call as a bricked device. Just an expensive paperweight on other words. The choice is yours. Read and understand thoroughly before you decide to go ahead. If you like to tinker then this should be a fun exercise.

The other claim that you can “play Netflix” on a browser on the Nintendo Switch without doing anything overly technical is only half true. Yes there is that so called secret browser that you can force to show and use much like you would a browser on your Mac or phone. It involves manually setting an IPv4 address as DNS in your Switch’s Internet connection settings.

While you can logon to a Netflix account or browse the catalog, that’s about all you can do there. When you start playing a movie Netflix will say the browser does not support the minimum requirements for streaming the content.

So you are left with a browser, that is awkward and clunky to use.

Don’t bother!

Get a tablet instead if you want a portable device for watching movies on the go.

Identify Songs Playing Using Smartphone

What nice and safe apps are there that I can install on iPhone or Android to identify songs playing from another source? Preferable to have no ads, unlimited use and free of charge.

ANSWER

A few years back when I was in that apps discovery phase on my Android and installing as many as I can even when those apps would hardly ever be used after the first try, I came upon Shazam. Was impressed by it. It was able to ID the songs quite accurately. It sometimes took a while, a few longer seconds, sometimes but it normally was able to pick up and tell me the song title and artist. The sound quality it is listening to also is a factor for proper identification. It did have some success on getting the songs right in a public place, like a bar or a cafe, where music was playing loudly and a lot of other noise around.

There are many sound discovery or music recognition apps out there for both Android and iPhone. I have heard of SoundHound or Musixmatch.

I have not used such apps for a long time. Shazam was free when it came out. No ads then. I might have installed it again years after, and as I recall the UI changed this time with ads too. But I could be wrong. It might have been a different app. SoundHound, Musixmatch and Shazam come with free and paid versions. Whether these apps have limited use for free versions, you can find that out or DON’T.

Try out those 3 apps, OR you don’t really have to go to all the trouble. Google Assistant on Android can do the same magic. Just ask it, “Which song is this?”. Type it or say it. Better the latter. I have done it several times, for example while driving and listening to a local FM radio station.

Apple’s Siri can do the same.

Getting an MYSQLDump error

I upgrade MySQL DB from 5.6 to 5.7 version not too long now with no issues happened after. But at that time I did not use mysqldump command. Now I tried to backup the database and gettting this error message:

mysqldump: Error: ‘Access denied; you need (at least one of) the PROCESS privilege(s) for this operation’ when trying to dump tablespaces

How to fix this error.

ANSWER

The PROCESS privilege requirement was added only in MySQL version 5.7.31. This is an expected behavior and affects mysqldump utility. There is a report here and some discussions –

https://bugs.mysql.com/bug.php?id=100219

If your user has no admin privilege to the MySQL database, the quick workaround is to add the –no-tablespaces option. The usage like below.

mysqldump --no-tablespaces -u user -p DB_NAME > BACKUP_FILE.sql

On the other hand, if you have admin access, then grant that user the PROCESS privilege like this:

GRANT PROCESS ON *.* TO user@localhost;

Be warned that such privilege is usually reserved for server administrator users. It works on a global context, so it cannot be specified on a per database approach. Granting just any user this PROCESS privilege is not a good idea. It may cause “data leaks” when sensitive queries gets exposed because this privilege can allow a user to see queries being executed in active sessions. This becomes more critical when the server instance is shared.

Accidentally deleted all in Git branch

HELP! What to do?

I made first commit. Noticed a file that is not supposed to be save with sensitive values. Did not want to get the history for this one file in there, that would be viewable still.

Proceed to revert that first commit, thinking it will go back when no files was committed.

All files are gone now as result! I cannot find in my project folder even recycle bin.

ANSWER

First commit? But you want to undo for a file or two? Easy peasy. No need for revert. It’s only 1 commit! Then you would not have been in this trouble you are now.

Delete the .git folder! Mind you this is before you should have done any git voodoo. Re-init git, add files, then commit. Then you’re done. You’re back in business without having so much down time.

Now going to the other solution. I have encountered this before like you. The files are still there. So to speak. Git knows it, since it has the history for that action. A simple git log will prove.

Normally, you can pick the files back one by one simply by using the checkout command. But first, get a list of these files, including full path to it. This will show all the files that have been affected or deleted in your case.

git status

THEN

git checkout path/to/filename

For a few files, this approach works. Not very convenient when you have dozens to hundreds of files to recover. This may be your situation too. For some reason, using a wildcard will not work.

git checkout *
git checkout path/to/*

It executes but does nothing.

Sometimes commands like below will do the trick. Or it won’t. YMMV. But may be limited to *NIX-compatible OSes. For Windows, use Git Bash for one.

git ls-files -d | xargs git checkout --

In my experience, I did the following steps in git.

git log
git checkout COMMIT_ID
git commit -m "Restore my files"
git checkout master

The first command is to get the commit ID.

Second is to checkout at that commit. Now you’ll be in limbo. You’re not back at master branch where you started out. Instead this checkout will be outside of master. You’ll see a message such as

HEAD detached at COMMIT_ID_SHORTENED

This is all good. Don’t worry. Just commit those files again. That’s the third command up there.

Then once done, checkout to master. The last command shown up there.

If for some reason there are files that conflict, the switch to master branch won’t succeed. Just add those conflicting files too.

git add path/to/file/name
git commit -m "Some more files"
git checkout master

Now all is good. Look at your folder. All files are there again.

Auto-create MySQL Database in Java

Many Java / JDBC / JPA examples show only how to create DB table(s) if not existing. Like putting the table defintion or DDL in a .sql file, where the program can pick it up and execute on run-time.

But not with the database itself.

How can database be created on the fly?

ANSWER

With JDBC this can be done as a parameter to the URL connection string.

In the example shown below –

datasource.url=jdbc:mysql://localhost:3306/SCHEMA_NAME?createDatabaseIfNotExist=true

The parameter (comes after ?) – createDatabaseIfNotExist – must be set at value of true.

As I recall, this works only after MySQL version 5.1.

Note: SCHEMA is MySQL speak for database. It is common to call that even with other products. Other databases or code implementations may also term it as CATALOG.

Create Fat .gitignore in Intellij

Rather than create my .gitignore file by hand or copy from a previous project, I do not prefer this method. Is there a quicker way to generate the .gitignore file with many of the things I don’t want to be tracked by Git to be included in it.

ANSWER

Intellij IDEA

Plugin: https://plugins.jetbrains.com/plugin/7495–ignore/

Add that to your Intellij IDEA app. There is a button in that page to automatically download and install this plugin. Make sure the Intellij app is running before hitting that button.

Or you could simply download, then install manually. Select the Versions tab in the plugin page. Choose the version you want to download. Find the zipped file in your “downloads” folder.

To install manually, head over to: Settings > Plugins > (gear icon) > Install Plugin from Disk

The gear icon might be different with other versions of IntelliJ.

The plugin should be activated already, not needing an app restart.

Eclipse

For Eclipse, I’m not sure of a plugin that has pre-defined lists. I can right click on a folder/file and add to .gitignore (Team > Ignore), is what I did before. Haven’t tried an Eclipse Marketplace search.

Visual Studio Code (VS Code)

Click extension then type in “gitignore” in the search box. Look for the extension by CodeZombie. Versions as of this writing is 0.7.0.

To use, do the following:

Start command palette (with Ctrl+Shift+P or F1) and start typing Add gitignore

Other

Another way is to go to gitignore.io OR github.com/github/gitignore and get a generated .gitignore template from there. Search/select the application, OS you want. Then copy/download the generated templates.