To make a short script to do this...
Use Notepad++ [or TextWrangler on MAC] to make a plain-text file that must be UFT8 encoded.
Name it say myUN.rb
It goes in your user's Plugins folder.
Find that using this snippet in the Ruby Console:
UI.openURL("file;///#{Sketchup.find_support_file('Plugins')}")
Then add one line of text as follows + return, substituting the desired code you wish to run, where I have put CODE [copy paste from the previous examples as desired]; you can also name the menu item as you wish - I've named it "myUN..."
UI.menu("Plugins").add_item("myUN..."){CODE}
After SketchUp restarts the new menu item should be seen in the Plugins menu - which is now called the 'Extensions' menu in newer SketchUp versions...
Select that menu item to run the code...
Also remember that you will need the Extension Manager Loading Policy set to Unrestricted to run your own 'unsigned' scripts...