How do I remove tinyMCE and then re-add it?

To cleanly remove an editor instance and avoid any errors use: tinymce.EditorManager.execCommand(‘mceRemoveControl’,true, editor_id); To reinitialize the instance use: tinymce.EditorManager.execCommand(‘mceAddControl’,true, editor_id); Be aware that when moving TinyMCE editors in the DOM you need to removeControl and addControl too, otherwise it results in JS errors. As of TinyMCE 4 the methods to remove and reinitialize an instance … Read more

How to use Attributed String in SwiftUI

iOS 15 and Swift 5.5 Text now supports markdown and also you can create custom attributes: You can even get defined attributes remotely like: iOS 13 and 14 You can combine multiple Text objects together with a simple + operator and that will handle some of the attributions: Each one can have multiple and specific … Read more

How to stop a DispatchWorkItem in GCD?

GCD does not perform preemptive cancelations. So, to stop a work item that has already started, you have to test for cancelations yourself. In Swift, cancel the DispatchWorkItem. In Objective-C, call dispatch_block_cancel on the block you created with dispatch_block_create. You can then test to see if was canceled or not with isCancelled in Swift (known … Read more

How do I save preference user settings in Java?

You can use java.util.prefs package. A simple example: // Retrieve the user preference node for the package com.mycompany Preferences prefs = Preferences.userNodeForPackage(com.mycompany.MyClass.class); // Preference key name final String PREF_NAME = “name_of_preference”; // Set the value of the preference String newValue = “a string”; prefs.put(PREF_NAME, newValue); // Get the value of the preference; // default value … Read more

Hibernate saveOrUpdate behavior

When you use .saveOrUpdate() Hibernate will check if the object is transient (it has no identifier property) and if so it will make it persistent by generating it the identifier and assigning it to session. If the object has an identifier already it will perform .update(). From the documentation: saveOrUpdate() does the following: if the … Read more

Getting Serial Port Information

I tried so many solutions on here that didn’t work for me, only displaying some of the ports. But the following displayed All of them and their information. using (var searcher = new ManagementObjectSearcher(“SELECT * FROM Win32_PnPEntity WHERE Caption like ‘%(COM%'”)) { var portnames = SerialPort.GetPortNames(); var ports = searcher.Get().Cast<ManagementBaseObject>().ToList().Select(p => p[“Caption”].ToString()); var portList = … Read more