Installing ngrok on OSX

You really want to try this if you all of a sudden have a localhost website to share to others but it’s troublesome to get onto the same network and lookup IP and stuff.

To install ngrok, just run the following. More details here.

brew cask install ngrok

Then have your localhost running. Here is a sample command to share your local directory. You can pick any port number. Let’s pick 8080 for example.

ruby -run -e httpd . -p 8080

Then involve ngrok

ngrok http 8080

You will see something like this

ngrok by @inconshreveable                                                       
Session Status                online                                            
Session Expires               7 hours, 59 minutes                               
Version                       2.3.35                                            
Region                        United States (us)                                
Web Interface                                    
Forwarding           -> http://localhost:8080 
Forwarding           -> http://localhost:8080
Connections                   ttl     opn     rt1     rt5     p50     p90       
                              2       1       0.02    0.01    0.23    0.45      
HTTP Requests                                                                   
GET /favicon.ico               404 Not Found                                    
GET /                          200 OK                                                

A publicly available URL, actually two, are created: https:// The abc123ef part will be different each time you involve ngrok. Now just send this URL to others and they will be able to access your localhost website.

You can also examine the incoming traffic at http://

Stopping ngrok is as easy as Ctrl-C.


Wuhan Coronavirus (2019-nCoV) Map (by Johns Hopkins CSSE)

Screen Shot 2020-01-30 at 1.54.17 PM

Half and Half vs Milk

Fat content:

Half and Half:

10.5% to 18%
Whole milk:

Reduced fat milk:

Semi-skim milk:

Low fat milk:

Skim milk:

0.0 to 0.5%

What is half and half? It is a simple blend of equal parts of whole milk and light cream. So milk and cream.


Unicode encodings in python

So “str” in Python 2 is now called “bytes,” and “unicode” in Python 2 is now called “str”.

Oh boy, that’s why I have been so confused working on both Py2 and Py3 on various projects.

It’s year 2020. From this point on, it’s all Py3. So I/O is all byte string, and try to keep unicode/str inside python. IO_byte_string.decode() -> unicode_string, unicode_string.encode() -> IO_byte_string. So:

with open(filename, 'rb') as f:
  byte_string =  # binary
  # external knowledge: data encoded in utf-8
  my_string = byte_string.decode('utf-8')
  # my_string is a list of "code points"
  # Output say, using 8859-1 (Latin-1)
  output_byte_string = my_string.encode('8859-1')


# external knowledge: data encoded in utf-8
with open(filename, 'r', encoding='utf-8') as f:
  my_string =  # code points

# Output say, using 8859-1 (Latin-1)
with open(filename2, 'r', encoding='8859-1') as f:


Python strings

I started out with “+”, then was told not to use it. So I listened and used “join”. Then later I used format. Now it seems that I should use “f”.

f'{s} {t}'               # 78.2 ns
s + '  ' + t             # 104 ns
' '.join((s, t))         # 135 ns
'%s %s' % (s, t)         # 188 ns
'{} {}'.format(s, t)     # 283 ns
Template('$s $t').substitute(s=s, t=t)  # 898 ns


No title

Good read:

Make something people want. It’s Y-Combinator’s motto and a maxim of aspiring internet entrepreneurs. The idea is that if you build something truly awesome, you’ll figure out a way to make some money off of it.

So I built something people wanted. Consumers wanted it, doctors wanted it, I wanted it. Where did I go wrong?

“To succeed, an offering must create value for all entities involved in the exchange—target customers, the company, and its collaborators.”

Strategic Marketing Management

Gato Barbieri – Europa (Earth’s Cry Heaven’s Smile)