When ALL your browsers begin to crash…

… and you are running whatever remained these days from the once glorious and truly excellent OS X operating system, then it’s probably yet another cool feature you got from Apple.

Yes, you can’t really search the web for hint or solution when NONE of your browsers work anymore. Thus – in order to read even this post – you need another computer. Can be virtual though. You can install one of the nice GNU/Linux distributions into VMWare/Parallels/Virtualbox and enjoy World Wide Web this way until you find that:

Apparently all web browsers in the latest Apple’s excuse for an OS can be infected with a single file located in your ~/Library/Preferences/

~/Library/Preferences/com.apple.SpeakSelection.plist

Removing this single file magically cured Chromium, Firefox, Safari, Brave… for me.

Solution source: https://discussions.apple.com/thread/255622280

Posted in Rants | Tagged , , , , | Leave a comment

VMware shared folders under GNU/Linux

If you ever hopelessly stared at this message

then at this menu

with its disabled, greyed-out options of “RE”installing VMware tools and no matter how long you looked at them the folders selected for sharing never wanted to appear on your guest OS (GNU/Linux in this example) then know that you’re not alone.

In an act of desperation you might have even tried to dig out the “VMware Tools” .iso images from the dungeons of the installed VMware applications directories structure. Only to be told that you should rather install open-vm-tools instead of stuff from said images, when trying to install from there.

Yup, this is all an elaborate prank, which VMware likes to play on its unsuspecting customers. Think like that: you get warning that the sharing won’t work unless you install… right, the “VMware Tools”. You can’t install those because the menu item for doing it is disabled. And of course folders sharing does NOT work, does it? Or… doesn’t it? Gotcha!

In fact it works, despite the warning signs and other stuff. Your shared folders are simply only not mounted

Do yourself a favour and first make sure open-vm-tools (and open-vm-tools-desktop if you’re using a desktop environment) are installed, and that you’ve rebooted after their installation. Although if you see the greyed-out “REinstall… in the menu then you probably have it installed already. Then insert this line into your /etc/fstab

.host:/	/mnt/hgfs	fuse.vmhgfs-fuse	auto,allow_other	0	0

You can thank me (and even more the original author) later. Source:

https://gist.github.com/darrenpmeyer/b69242a45197901f17bfe06e78f4dee3

Posted in GNU/Linux, Rants | Tagged , | Leave a comment

RGB is bad, you need something else for your Mac, right?

Namely you need YPbPr. What can possibly go wrong? Apparently a lot (in terms of the quality of your monitor’s picture). Like you can have:

  • ugly, blurry picture with small text barely readable
  • ugly, over-“sharpened” picture with texts mostly readable despite the annoyance but colours often being off due at least to the edges’ convolution effects affecting small screen elements

I haven’t analysed the exact mechanisms, which cause these special effects but what I noticed is that my picture is perfectly fine on:

  • OS X 10.5
  • OS X 10.6
  • OS X 10.7
  • OS X 10.8

Where booting the default installation and setup switches monitor into YPbPr mode. Then it gets the first effect of Gaussian Blur applied to the whole display area starting with OS X 10.9, which coincides with the monitor being run in RGB mode by default. On the other hand running the default setup of current at the time of writing “macOS 12.x” makes the monitor run in YPbPr mode and results in the second set of effects. Now I remember some good time ago I eventually fixed this by “forcing the Mac to output colour in RGB mode”. Although I can’t be sure anymore that I used this fine blog post or that even finer github gist, it definitely rings some bells. So I put links here for “posterity” 😉

sudo mkdir -p /Library/Displays/Contents/Resources/Overrides
cd /Library/Displays/Contents/Resources/Overrides
sudo curl -O https://gist.githubusercontent.com/ejdyksen/8302862/raw/patch-edid.rb
sudo ruby patch-edid.rb

And boom/bingo/voilà/whatever your pronou… erm exclam of the day is:

P. S. Rumour has it that the issues are mostly/exclusively? showing up when using Dell monitors. Can neither confirm nor deny

UPDATE: Apparently this no longer works on Apple’s ARM architecture machines 😦

Posted in OSX | Tagged , , , , , | Leave a comment

Synology DSM e-mail notifications

For many years I’ve been enjoying very performant and stable e-mail service provided by Google’s “G-Suite” while Google’s been enjoying sniffing through all my organisation’s users e-mail communication in return. Obviously for sensitive info an extra encryption layer is employed but since this was a tiny minority of the general e-mail volume, it was basically a type of symbiosis. This win-win relationship was recently abruptly severed as Google was kind enough to inform us about imminent upgrade to the services we were using. The said “upgrade” was of course to be performed free of any charges. It’s just that the “upgraded” services are supposed to be paid more or less double the industry average per user fee. No need to tell that nowhere in the letter, there was any mention about the prices. The text was focused purely on how much we are all going to love all the new wonders we’d get if we were quick to “switch now and save!” (sic!).

Time to set another mail system up. Just this time not for an external customer but for my company.

Surely that was a job, which interfered with current important tasks but since it’s been chewed over and postponed a good number of times already, this time there were no excuses left. So… thing’s been set up, users and all their crazy aliases migrated, rather sizeable e-mail base synchronised over, MX-es switched, another sync and boom! Or rather “voila” It Just Works™ Every e-mail client around the organisation seems to be happy with the new setup. Not that there are so many of them to choose from 🙂

Except… Synology NAS servers admin notifications arrive now as e-mail rejection notifications rather than regular messages XD

If you ever encounter the problem of e-mail admin notifications (not to be confused with users mail if you use those on the NAS – we don’t) being rejected with

535 5.7.8 Error: authentication failed: Invalid authentication mechanism

then you may realise that Synology expects only one authentication method to be always available on the server it communicates with: LOGIN and there’s no way to select a different one. Good that they don’t insist on sending credentials in plain text without SSL/TLS! Nor insist on employing TLSv1.0 for example as some still do.

I see basically only two options for tackling the issue:

  • use another, external mail/submission server, which supports LOGIN (sender’s domain restrictions may apply)
  • enable LOGIN on the server you initially didn’t want to have it enabled on

None of the two is perfect but well, you can’t have everything, right? Where would you put it?

Posted in DevOps, Rants | Tagged , , | Leave a comment

Phoenix Contact

In case you ever wondered (or I forget again what to type in order to find where to buy them) what are those dang plugs/terminals,

which are so widespread in rack mounted studio AV equipment and so always missing from every piece of it. They are

“Phoenix Contact(s)”

Posted in Uncategorized | Leave a comment

Where are the FSCKin’ reCAPTCHA settings?!

They are at:

https://www.google.com/recaptcha/admin/

In case you lose tons of time every time you try to find them _again_

P. S. This works for me but I heard rumours that this may depend on the type of account, your status in the organisation or water level in Mare Tranquillitatis. So don’t come after me if yours are not there

Posted in Coding, Rants | Tagged , , | Leave a comment

Rendering Svelte components in Phoenix templates

In case you don’t know what Svelte is, it’s probably the first thing ever in the node-js-is-a-cancer world that actually makes some sense, rather than just being the future, man! Right, there was jQuery, which not only made sense but in fact felt like a pure Godsend in it’s time. But this was long before node times. Before times when things like left-pad get downloaded millions of times every week and is-odd gets close to half a million of downloads. So yes, in preparation for eventually leaving this Right-Tool-For-Virtually-Any-Job behind (and moving to wasm or something), it still might be worth to check Svelte out. If OTOH you don’t know what Elixir or Phoenix is that’s another story, but I’d say also very much worth checking out. In my not so extremely humble opinion it’s even more worth one’s attention than anything-you-can-think-of-js. Right, even if I have a few rants to write about Elixir/Phoenix too 😉

Now when it comes to marrying the two together in the web development context, there are a few choices which seem to come in (chronological) order:

there are obviously other options but the three listed above build on the same concept and allow straightforward rendering of Svelte components right out of your .*eex (or .slime) templates. It seems that the original blog post’s concepts got turned into a simple lib, and since the lib’s author apparently lost motivation to maintain it, another lib author stepped-in and built on the original ideas further. At the time of writing also only the last one has been updated to be compatible with current at the time Phoenix 1.6.x and its hugely improved esbuild based build approach. It is also actively developed and it might be that at the time you read this post, it already addressed the issues listed below either in a similar to mine or better way.

What’s not so rosy then? Well, all three of the above share at the time of writing the same original sins of the first one:

  1. Forcing a <div> element around every Svelte component being rendered, which may on occasions lead to a CSS bug requiring more time to fix than you’d like to devote to it
  2. Forgetting that id attribute has to be unique in HTML document, effectively enforcing artificial limit of only one instance of any Svelte component on the page
  3. Passing props as a set of data-* attributes, which can quickly get ugly, the moment it starts growing beyond your name or “world” passed to hello.svelte

While I haven’t addressed the last one (yet?), addressing the other two seemed easy enough. What I did is

An elixir helper module:

defmodule PhxAppWeb.Helpers.Svelte do
@moduledoc """
Svelte rendering helpers
"""
	def svelte(name, props, elem \\ :div) do
		Phoenix.HTML.Tag.tag(elem, [data: [props: encode_props(props)], id: generate_id(name)])
	end

	defp encode_props(props) do
		case Jason.encode(props) do
			{:ok, encoded} -> encoded
			{:error, _} -> ""
		end
	end

	defp generate_id(name) do
		"svelte-#{String.replace(name, " ", "-")}-#{System.unique_integer([:positive])}"
	end
end

which I added to my phx_app_web.ex file in the private view_helpers function:

	defp view_helpers do
		quote do
			# Use all HTML functionality (forms, tags, etc)
			use Phoenix.HTML

			# Import basic rendering functionality (render, render_layout, etc)
			import Phoenix.View

			import PhxAppWeb.ErrorHelpers
			import PhxAppWeb.Gettext
			import PhxAppWeb.Helpers.Svelte
			#[…]

			alias PhxAppWeb.Router.Helpers, as: Routes
		end
	end

to have the svelte helper function globally available. Then rewrote this file into

/* assets/js/svelte.js */
const context = require.context("./svelte", false, /\.svelte/);

window.onload = function() {
	context.keys().forEach((fileName) => {
		const componentName = fileName.replace(/\.\/|\.svelte/g, '');
		const targetElements = document.querySelectorAll(`[id^="svelte-${componentName}-"]`);
		const component = require(`./svelte/${componentName}.svelte`);

		for (const targetElement of targetElements)
		{
			var props = targetElement.getAttribute('data-props');
			var parsedProps = {};
			if(props) parsedProps = JSON.parse(props);
			new component.default({target: targetElement, props: parsedProps});
		}
	});
};

plus imported it in my assets/js/app.js with import "./svelte.js"; and voila…

with simple

= svelte "component_name", props_to_pass, :span

or

<%= svelte "component_name", props_to_pass, :span %>

I have three pencil icons on the right, which are three instances of the very same Svelte component coexisting happily in non-div elements within a single page / HTML document. They might not look like much but clicking on them opens another layer with movable windows with forms and other c00l 1337 stuff 😉

P. S. Please note that the above is valid for “webpack” based builds. This post does not address integrating Svelte into Phoenix 1.6.x “esbuild” based processing. I plan another post covering exactly this. In the meantime you can check both the already mentioned Svonix lib or this demo respository by yendrisrogelio for some clues.

Posted in Coding, Elixir | Tagged , , | Leave a comment

Getting into Synology NAS with SSH

You enabled SSH on your Synology NAS, you read that only administrators are allowed to SSH into the NAS. Yet when you try you get the nonsensical

Too many authentication failures

message even if it’s only the very first time you tried. As mentioned here

what you need to do is to add an option to your command line

ssh -o IdentitiesOnly=yes user@host.domain

or SSH configuration

Posted in Uncategorized | Tagged , , | Leave a comment

Couldn’t start client ElixirLS

If after installing the ElixirLS extension for VSCodium you keep getting the dreaded “Couldn’t start client ElixirLS” error message then this post

https://github.com/JakeBecker/elixir-ls/issues/80#issuecomment-393634366

might help you to defeat the beast. It helped me at least. Apparent issue is that shell scripts located in my case under

.vscode[-oss]/extensions/elixir-lsp.elixir-ls-0.9.0/elixir-ls-release/

which is a bit different than what the post author used in his case, were all using shebang but had no execution bit set. Setting that bit on all files, names of which end with .sh made it all work as expected.

chmod +x *.sh

Is the magic you want to employ after cd -ing into the appropriate directory. Similar actions may help in case of Visual Studio Code and ElixirLS extension, but I haven’t tried so don’t blame me too much if it doesn’t.

P. S. And don’t ask me why this doesn’t help on your Windows machine, okay? 😉

Posted in Coding, Elixir | Tagged , , | Leave a comment

Rotating a View Is Simple Not Easy

Thanks to ix4n33 for the title… as I simply reduced, reused and recycled his one.

So… if you didn’t notice, I got to the NSView, specifically NSImageView rotation business recently. It happened while adding a requested feature to my out-of-frustration created program. EasyPeasy, right? I am sure you guessed already that I wouldn’t be writing this post if it was oh-so-easy.

While my case (and programming language) was slightly different than ix4n33’s – I was supposed to add support for the trackpad gesture based rotation rather than hitting a button on the UI – I went through all the same stages he described and multiple conflicting, stuck-up, half-witted, scruffy-looking “solutions”. Not much of a surprise as on the lower level it boiled down to the very same problem: How to rotate an NSImageView (No, not an IKImageView!) around its centre without losing one’s mind. Or at least patience. While I was able to find various pieces of the actual solution scattered around StackOverflow and other corners of the World-Wide-Web – this nicely crafted and illustrated post by ix4n33 has it all in one place!

TL;DR

1. Set the animation layer’s anchor point (even if it is supposed to be set so by default)

[[mainImageView layer] setAnchorPoint:NSMakePoint(0.5, 0.5)];

2. Move animation layer’s position to the centre of the view’s frame

[[mainImageView layer] setPosition:NSMakePoint(NSMidX([mainImageView frame]), NSMidY([mainImageView frame]))];

3. Create a CATransform3D structure (even if all you want is a simple 2D rotation), where you give radians based value for rotating around Z-axis only vector

CATransform3D rotation = CATransform3DMakeRotation(cumulativeRotation / (180 / M_PI), 0, 0, 1);

4. Do what you originally expected to be able to do in one simple API call

[[[mainImageView animator] layer] setTransform:rotation];

P. S. If you try this at home – don’t forget to “turn your view into a layer-backed view” either programmatically or in Interface Builder…

Posted in Cocoa, Coding, Objective-C, OSX | Tagged , , , , | Leave a comment