Thursday, December 5, 2019

Best Markdown Editors for Windows, Linux, and the web

Markdown is a lightweight markup language, allowing people “to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML)”. An excellent Markdown Syntax Guide is by Daring Fireball. Sites such as GitHub, reddit, Diaspora, Stack Overflow, OpenStreetMap, and SourceForge use Markdown to facilitate discussion between users. GitHub uses “GitHub Flavored Markdown” (GFM) for messages, issues, and comments. It differs from standard Markdown (SM) in a few significant ways and adds some additional functionality.
As Markdown becomes more popular, new tools have been developed to cater to writing. This post won’t enumerate all or most tools at hand. Instead, I will just list a couple of my personally favorite Markdown editors on different platforms.
MarkdownPad is a full-featured Markdown editor for Windows. It supports instant HTML preview, spell check, custom css, etc.
ReText is very similar to MardowPad, but it works on Linux. It is written in Python using Qt libraries, therefore is able to run on any platforms. It supports full markdown syntax, live preview, HTML/pdf/odt/Google Docs export etc. To install the latest version on Ubuntu, use
>> sudo add-apt-repository ppa:mitya57/retext-beta
>> sudo apt-get update
>> sudo apt-get install retext
Markable is a remarkable online Markdown editor. It supports syntax highlighting, line preview, and file sharing with Dropbox and Evernote. For small task, it is my favorite editor.
EclipsegeditSublime, etc all provide plugins that add support for Makrdown. I will gradually add the links after I REALLY use them:

D-link DIR-628 connection dropouts

Problems

I am using a D-link DIR-628 and experiencing regular Wireless signal dropout. It is occurring on multiple wireless devices in my home, including a Macbook, an iPad, and an iPhone. It is hard for them to connect to the router when I come back home, and it frequently loses connection thereafter.
I am sure there is no problem of the incoming internet because my desktop that connects the internet via ethernet never dropouts. BTW, I am using a 5GHz wireless network, so there shouldn’t be many conflicts.

Suggestions

  • Ensure DNS IP addresses are being filled in under Setup/Internet/Manual.
  • Turn off ALL QoS GameFuel options under Advanced/QoS or Gamefuel.
  • Turn off Advanced DNS Services if you have this option under Setup/Internet/Manual.
  • Turn on DNS Relay under Setup/Networking.
  • Setup DHCP reserved IP addresses for all devices on the router under Setup/Networking
  • Set Firewall settings to Endpoint Independent for TCP and UDP.

How to fix Python SSL CERTIFICATE_VERIFY_FAILED

Here I explain how to fix Python SSL errors when downloading web pages using the https protocol in Python (e.g. by using the urllib, urllib2, httplib or requests. This error looks like (possibly with a line number different from 509):
1
2
self._sslobj.do_handshake()
 SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
Server certificate verification by default has been introduced to Python recently (in 2.7.9). This protects against man-in-the-middle attacks, and it makes the client sure that the server is indeed who it claims to be.
As a quick (and insecure) fix, you can turn certificate verification off, by:
Set PYTHONHTTPSVERIFY environment variable to 0. For example, run
1
2
export PYTHONHTTPSVERIFY=0
python your_script
or
1
PYTHONHTTPSVERIFY=0 python your_script
Alternatively, you can add this to your code before doing the https request
1
2
3
4
import os, ssl
if (not os.environ.get('PYTHONHTTPSVERIFY', '') and
    getattr(ssl, '_create_unverified_context', None)):
    ssl._create_default_https_context = ssl._create_unverified_context

How to check README.rst file before uploading to PyPI

During the first launch of a package, I went through a series of releases because of rendering issues of README.rst on pypi. I pulled up my new package on pypi and was met with unseemly, unformatted text instead of a spiffy display. To avoid that, you can use
1
twine check dist/*
It tested the READEM.rst locally, and it would “warn” you errors.
See: https://packaging.python.org/guides/making-a-pypi-friendly-readme/#validating-restructuredtext-markup

Notifications on both apple watch and phone?

On Apple website, it says “Your notifications will go to your iPhone or your Apple Watch, depending on the device that you’re using.”
When I’m at home, I have my phone, computer, there’re clocks all over the house. So I take the apple watch off. However, since all notifications will send to my Apple Watch, I won’t get them from my phone. What can I do? There are two ways:
  1. On the Apple website, it also says “If your iPhone is locked or asleep, you’ll get notifications on your Apple Watch, unless your Apple Watch is locked with your passcode.” So the first solution is to set passcode on your watch. You’re probably thinking, “But, I don’t want to enter a passcode on that tiny screen every time I want to use my watch.” Luckily, that’s not the case. You only have to enter the passcode on your Apple Watch in a few situations, such as when:
    • You reboot your watch You manually lock and then unlock your watch
    • You remove your watch from your wrist and put it back on
    So, if you wear your watch all day, you’ll only have to enter the passcode once when you first put it on.
  2. The second solution is set “Airplane Mode” on your watch; that is to make your watch temporarily disconnected with your phone.

Install Qt5.7 binary on Ubuntu 16.04

Run
1
2
3
sudo add-apt-repository -y ppa:beineri/opt-qt57-xenial
sudo apt update
sudo apt install qt-latest

Adding GPUs to Goolge Clout VM

Installing GPU drivers

  1. Follow the instructions on https://developer.nvidia.com/cuda-downloads, to install cuda10.1 (the deb local version works)
  2. Install cudnn
    1. download cuDNN runtime library for Ubuntu18.04 online: https://developer.nvidia.com/rdp/cudnn-download
    2. sudo dpkg -i libcudnnXXX.deb
  3. Setup library path
    1. export PATH=/usr/local/cuda/bin:$PATH
    2. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64

Install Apex

NOTE: make sure pytorch and apex, and cudnn are compatible with cuda version (currently cuda10.1)
  1. git clone https://github.com/NVIDIA/apex
  2. cd apex
  3. python setup.py install --cuda_ex