Yearly Archives: 2023

Blocking Twitter and Other Nuisance Sites with BlockSite

It’s very common for news articles to contain links to Twitter. Some lazy writers even create articles that are nothing but a page of Twitter embeds.

I think Twitter is trash and never want to visit the site, and sometimes it’s not obvious that a link ends up on Twitter, especially with the widespread use of URL shorteners on the web.

I found a quick solution that works well via a plugin called BlockSite. I use both Firefox and Chrome, and it’s available for both.

BlockSite for Chrome

BlockSite for Firefox

There’s a lot more to it than just blocking garbage sites like Twitter, including things like setting up distraction-free hours to block social media during your workday, so check out their website for more info.

Here’s an example of the plugin preventing a visit:

BlockSite Plugin Preventing Twitter Access

BlockSite Plugin Preventing Twitter Access

PostgreSQL Command History

The command-line PostgreSQL database client keeps a command history.

Much like on a Linux console, you can use the up arrow to scroll back through previous commands. This can be handy if you want to repeat a command, or to change a parameter on a long query.

One other thing that is less widely-known is that you can view the ENTIRE history by typing “\s”. Backslash-s will function pretty much the same as the Linux “history” command, and can give you multiple pages of commands.

Much like the history of the Bash shell, the Postgres command history is stored in your home directory in the hidden file .psql_history. Although this is handy, it can also be a security risk to keep old commands where prying eyes can find them. You can easily delete this file, or clear it using the command:

 truncate -s 0 .psql_history

I like the truncate command because it’s a nice, clean, one-step way to clear a file without deleting it.

Full Support for Ukraine

I don’t say much about politics here, because on the internet nobody cares and nobody’s opinion is important.

BUT

I am a US citizen. I am 100% in favor of military support for Ukraine. I don’t care how much it costs, and I’m totally OK with my taxes going up if need be. Russia is a terrorist state and must be defeated, no matter the cost. That includes nukes.

Russia is the aggressor. They were not provoked. The war in Ukraine is nothing short of imperialist ambition. The idea that “We were great and will be again” has killed tens of thousands of people, and is nonsense at its core. There will never be another Roman Empire. Give up.

Russia must be defeated, dismantled, and demilitarized. It’s the only path forward if you want world peace.

If you visit any of my websites or consume any of my content, you should know that a not-exactly-specified (because it varies depending on my monthly budget) amount of my earnings are going toward supporting Ukraine.

Russia has nothing to offer this world until and unless it decides to withdraw from Ukraine and give back all that it has stolen. Anything short of this requires the complete destruction of the Russian “empire”. I use quotes because the Russian “empire” is a has-been and its military is a sad joke.

How to Insert Values Into a Table from a Select Query in PostgreSQL

I recently had to do a data migration where I needed to populate a new table with some data from another table.

Rather than perform some sort of export, transform, and import, it was much easier to do this via a select query within Postgres itself.

Although you can use the star operator, it’s safer and smarter to name fields specifically, in order. In addition, you should manually verify your select query first.

In my case, there were a set of a few fields I wanted to insert, and converted into a select query, looked like this:

SELECT date_added, description, last_updated, name, type FROM information;

This gave me all of the fields I wanted, and I verified that the data looked good.

Next, I added this to an insert query:

INSERT INTO information_subset (date_added, description, last_updated, name, type) SELECT date_added, description, last_updated, name, type FROM information;

Although it’s something that seems like it might be complex, inserting into one table using data from another is quite simple in Postgres and most other databases.

Using Location to Assume User Language

My first language is English. I live in Uruguay, and while I’m comfortable and nearly fluent in Spanish, sometimes I’d rather use a website in English.

It is EXTREMELY common for a website to see the location of my IP address and assume they should send me a page in Spanish. This is perfectly fine, because everyone in Uruguay speaks Spanish. Not everyone has it as their first (or preferred) language given the number of immigrants here (especially from Brazil), but everyone speaks at least SOME Spanish here.

The other thing that sites may use is the language setting of your web browser. This is also a reasonable approach, although less common. I have one computer set to English and one set to Spanish, and I’ll sometimes get different versions of a site depending on which computer I use. This is mostly OK, but there are an unreasonable number of computers that have the language set to English (the most common default) even though the users don’t prefer English. There are also computers used by multi-lingual households, so using the computer’s language setting is an assumption at best, and probably less accurate than using someone’s location.

Of course, the right thing to do after you’ve made an assumption about the user’s language is allow them to change it. Typically this is a link or button somewhere along the top of the site. Although sometimes this will be a flag icon, that’s less than ideal when you’re dealing with countries that have multiple languages (Belgium, for example). People from that country have learned to adjust, and can pick the French, Netherlands, or even German flag if they need to.

The problem comes when a website doesn’t give someone the chance to change the language they’re viewing. Not only are geolocation services not 100% accurate, but just because you are IN a place doesn’t mean you are OF a place.

Sure, auto-translation tools are nice, and they get you 80% of the way there, but they rarely understand context, words with multiple meanings, regional word usage, or any of the other Human nuances. Maybe some day, but not today. So it’s important to allow a user to select their preferred language.

Sometimes it’s easy to change the language manually by hand-editing the URL. For example, these urls:

es.wikipedia.org/page-name
example.com/es/page-name
example.com/page-name?lang=es

Can easily be changed to:

en.wikipedia.org/page-name
example.com/en/page-name
example.com/page-name?lang=en

Where it gets really ugly, and I’ve seen this with media/streaming sites more than anything else, is when you deliberately visit a page in a specific language, and you are force-redirected back to the language you didn’t want.

The only hope for sites like that is to use a proxy server. Or close the browser tab. You should never force a language on a visitor if your site is available in other languages.

And if you find a site with this bad behavior, please send them a message letting them know the error of their ways. Maybe they’ll eventually learn.

 

MusicSrch Improvements

It’s been a long time since I’ve worked on MusicSrch.

For the past few years, I really didn’t have any time for side projects, and a few searches were very broken on the site due to changes in the various third-party websites. It needed some serious rehab.

I spent a few days fixing things and improving various features, and now it’s a lot better.

Give it a try at https://musicsrch.com

I plan to spend a lot more time working on it this year, and there are more sites I want to add to search.

Why Do So Few People Develop Apps for Windows?

There are a lot of reasons so few people develop for Windows anymore.

We’ll skip the obvious ones:
– There’s a whole lot more growth in mobile apps.
– Most of the apps that people could want or need on Windows have already been written.
– Many apps make more sense as websites, so every platform can access them.

For apps that make more sense on a desktop PC, such as audio/video production and 3D design, and all of the other sorts of things that are not optimal on a 5-inch screen or in a stateless system, there’s a much more painful reason:

MICROSOFT’S DEVELOPER ECOSYSTEM IS HORRIBLE.

For example, the answer to this question:

What framework should I build my app with?

It is almost impossible to answer, and the official answer changes every year or two.

Win32?
WPF?
WinForms?
.NET MAUI?
WinUI?
Xamarin?
WinRT?
MFC?
Qt?
wxWidgets?
Silverlight?
Universal Windows Platform (UWP)?
Windows App SDK?
Progressive Web App (PWA)?
MSIX, MSI, or EXE installer?
Are any of these things different names for the same thing? (yes)

Good luck. Microsoft has come out with many new technologies that were “almost finished”, and each one has had some glaring omissions and dropped some important technologies or features that will probably never be finished before the system is replaced with something else. I know this pain all too well since I’ve worked with text-to-speech and audio applications extensively.

And, of course, when one system supersedes another, they don’t put a disclaimer on the docs saying “you should use this new thing instead” and provide a migration guide, and many of the docs don’t even have a date so you at least have some idea whether it’s current.

In some of the latest nonsense: In the Windows Store, you can submit an app with an MSIX installer or an MSI/EXE installer. You can set an app with an MSI/EXE installer as paid, but you CANNOT ACTUALLY CHARGE MONEY FOR IT. I don’t know who designed a system like that, but they were probably drunk at the time. Of course, I didn’t learn this until after I went through the entire process of getting an app approved for the store.

Another aborted effort was enabling ad-based monetization of free apps distributed via the Windows store.

Why is it that every mobile operating system (even the ones with only a handful of users) has managed to get this right, and Microsoft just can’t figure out how to build a system that people actually want to build a business around?

I like building desktop apps, but Microsoft has done everything they possibly can to make it a nightmare to support Windows. Nowadays you can probably only make money writing Windows apps if you’re writing malware.