Blog

Color flatting for Linux!

Hello everyone! If you’re like me, you’ve spent plenty of time thinking, “I wish Linux had an automated color-flatting tool.” Well, your days of wishing and hoping are over, because I have produced exactly the tool you’ve been wishing for. Behold:
pyflatter

For more information, check out the PyFlatter page, or just go download it on GitHub. Enjoy!

Convert rich text to Markdown

Markdown is a nice simple markup language which you can use to format type in plain text. There are lots of programs which can interpret it and convert it to common rich-text formats. Ah, but what if you want to go the other direction, and convert rich-text to Markdown? What then? Well, you do have options. Here are three of them.

Method One

This is the easiest method. Save your text as a Word document (you can do this in Open/Libre Office if you don’t have Word), then go to this amazingly awesome automatic converter script. I have found this to work very well in general. I can’t vouch for its security, though, so if you need to convert something confidential, you’ll need to move on to Method Two.

Method Two

This method makes use of the find-and-replace tool in your rich-text editor and is inspired by these delightful instructions.

OpenOffice/LibreOffice:

  1. Open the find/replace box, drop down “More Options” and check Regular Expressions.
  2. In the Search For box, type: (.*)
  3. Click the “Format…” button and select Italics (don’t touch other options)
  4. Check “Including Styles”
  5. In the Replace With box, type: _$1_
  6. Click Replace All
  7. If you’re lucky, your italic text should now be wrapped _like so_
  8. As needed, adapt the instructions above for bold, underline, etc.
  9. Copy the resulting text into a plain-text document, and save. Voila!

Microsoft Word (tested in 2010 edition):

  1. Open the find and replace box, click the “More >>” button, and check Use Wildcards.
  2. In the “Find what:” box, type: (<*>)
  3. Click Format -> Font (at the bottom of the dialogue) and choose Italic from the menu (don’t touch the other options)
  4. In the “Replace With” box, type: _1_
  5. Click Replace All
  6. If you’re lucky, your italic text should now be wrapped _like so_
  7. As needed, adapt the instructions above for bold, underline, etc.
  8. Copy the resulting text into a plain-text document, and save. Voila!

Method Three

If all else fails, try this. This method is convoluted and difficult, but it will eventually turn out some Markdown for you. Don’t say I didn’t warn you!

  1. Get Pandoc. If you’re on Linux, it’s probably in your repository. If not, you can download Mac or Windows binaries here.
  2. Save your file as an HTML document. I used Open Office to do this, I’m guessing Word would work as well but I didn’t test it. I did test AbiWord, but the HTML documents it produces are formatted really stupidly and don’t work for our purposes. Note: Do not use Open Office’s “export” feature (use Save As instead), as it seems to cause problems too for some reason.
  3. Use Pandoc to convert the HTML to Markdown. Basic console use is outside the scope of this tutorial, so hopefully this part is self-explanatory. The command is structured thusly:

    pandoc inputfile.html -t markdown -o outputfile.txt

     
  4. Check your output file for excessive line breaks. This is the fault of the way that OpenOffice exports HTML files. For some idiotic reason it puts in tons of line breaks. If your text has no extra line breaks, congratulations! You’re done! If not, proceed to Step Five.
  5. Use this online tool to nix the excessive line breaks. I sure hope this tool is still around when you or I next need it, because it’s a godsend.
  6. Repeat as necessary.

Fix GRUB in two easy steps

A little mini-tutorial here, brought to you by the school of Learning Things the Hard Way. I don’t know about the rest of you, but lately I’ve been having a lot of trouble with Linux installs failing to set up GRUB properly (particularly Ubuntu-based distros, for some reason). So, the following mini-tutorial is the result of a couple hours of headaches today. I’m not promising that it will work in every case, but if you’re having issues involving GRUB either not existing or not including options to boot one of your OSes, you might as well give this a shot.

  1. Use Super Grub Disk to boot into your Linux install.
  2. Run sudo update-grub from a console.

If you’re lucky, that will fix GRUB very nicely. It should be noted that this does require you to have some semblance of a working grub installation, however. In the event that you do not, I’d suggest running the Ubuntu Boot-Repair utility. In some cases, in fact, that may be all you need to do. As for me, it didn’t detect my Windows install, but it did succeed in getting GRUB installed, which is more than I can say about the original OS installer. Good luck everyone!

Monitor-Switching Hotkeys for GNOME

I just set up something really convenient for myself and I have to share it, though it’s somewhat outside of the normal scope of this blog. I use a laptop that’s normally connected to a full-size monitor, so I often have to switch between two different monitor configurations–kind of a hassle. But not anymore, because now I can switch using hotkeys. Here’s how it’s done:

  1. Get the monitor config tool “ArandR” ($ sudo apt-get install arandr)
  2. Use it to create and save two monitor configurations, one for the laptop and one for the main screen. These configuration files are actually shell scripts.
  3. Run gconf-editor and navigate to apps/metacity/keybinding_commands. Set the values of two commands to the paths to your shell scripts. (i.e., /path/to/script.sh)
  4. In apps/metacity/global_keybindings, set the hotkey combination for the commands you just set.
  5. Enjoy easy monitor configuration!

Thanks to this tutorial for showing how to set the hotkeys. Note that this uses Metacity, so it will not work if running other window managers, such as Compiz.

   

©John W. Allie 2018. | Contact?