I Forgot to Die

I had a pleasure of reading I Forgot to Die by Khalil Rafati. I read the book in a single day, and here are my thoughts. The book is an easy read. It has a very flow of consciousness kind of vibe so it’s easy to pick up, and reading it was enjoyable. At the same time, it’s not some hugely intellectual book - it’s rather simple in prose and sentence structure.

  1. Some people get lucky, and have stars line up for them despite all their troubles, given that they are motivated and willing to change. I feel that Rafati, even with so much time lost as a junkie, was able to pull himself up because he was willing to change. However, what really questions me is that why did he choose to change on the 9th time he overdosed? Why couldn’t it have been earlier, and why couldn’t it have been later? What was special about this time that made him start digging himself out? I mean, the past 8 times he overdosed, he might have thought that this was as low as he could get. But he kept sinking lower and lower. Similarly, why do people choose to exercise and get in shape, or get their shit together, when for the past God knows how many years they’ve been neglecting? I’m always curious of what is the last straw on the camel’s back that prompts people for these drastic changes.
  2. Usually addiction start with little things, and they are very hard to escape once you’re pushed to the deep end. Addiction is super-vicious cycle. Maybe it’s perhaps the way we’ve been built? If something is good, we go do it over and over. My thought on this is that human psychology is deeply rooted in present-focused gains. For many animals, the next day isn’t guaranteed. So instinctively, we are not used to planning ahead for years, or even months. So long in our history there was no guarantee that we’d even be alive the next day, so all our decisions gravitate towards optimizing for the next X span of minutes. So in terms of addiction, I think you start reinforcing that part of the brain for immediate need and viciously strengthen the neurons that are part of that primitive wiring.
  3. NO ONE starts out as a full blown addict. It creeps on you gradually. This principle is the same for life. No one becomes fat the next day wake up, or people amass significant amount of wealth when they wake up the next day. It’s a gradual process. No genius is born one day and the next day comes up with the Theory of Relativity. It’s a matter of gradual, slow progress until you look back and say, dang, I’ve come a long way…

    For me, I’d like to ask myself: have I moved the ball forward, farther than it was yesterday? That’s all that matters. To become better and propel yourself forward.

  4. The last page of his book had an impact on me. He says that, after exploring many different religions and ideologies, he ultimately cites Jesus: Love your God and neighbors, and states that is the only thing you need to know. This is somewhat true. Loving God can mean different things, if you don’t believe in the existence of God. One can interpret it as respecting the divine and existence of human life. But I digress. I think this statement is universal in nature, and religion independent. I think that would be the primary criteria that one would be judged when one meets their maker.
  5. At any point in life, people can turn their life around and just go for it. It’s simple. Work hard and have a laser focus. But it isn’t easy. Nothing in life that is ever worth it is easy, it seems.
  6. Don’t invest in things that you don’t understand or outside your realm of expertise. I think one part of the book he invested in some financial instruments and lost all his money because he didn’t pull out.

One day, when I visit California, I would like to go to his establishments =D.

Textbelt with Docker

** TL;DR ** I made a text server Container with everything in it using Docker for Textbelt.

So back in December I decided to attempt to use the following technologies to setup Textbelt:

  • Google Cloud compute
  • Node.js
  • Textbelt

I did all the setup and created the environment, and I got it to get myself a free text sending message, limited to I think 100 free text messages per day. I got this thing to work, and then wrote a simple text scripting app to send my friend a text every 30 seconds, which was kind of fun.

But the problem with this is that, it’s not portable! So this time, I want to

  • Document the steps I would take to setup this process
  • Make a Docker container so that I could easily run it on Google Cloud Compute, Amazon, Azure, wherever!

Now at this step, I got the latest debian container, and logged in but I was logged in as root. There is something wrong about logging in as root, so I did some Googling to get around it. So the easiest way seemed like making your own Dockerfile….

so Here it is. Replace username with your username:



#courtesy of https://stackoverflow.com/questions/47876144/can-you-start-a-process-inside-a-docker-container-as-root-while-having-the-defa
FROM debian:latest
ENV user_name user
RUN apt-get update
RUN apt-get install -y sudo
RUN useradd --create-home -s /bin/bash ${user_name}
RUN echo "${user_name} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${user_name}
WORKDIR /home/${user_name}
USER ${user_name}
CMD /bin/bash
#this line is from treehouse
RUN sudo apt-get -y install build-essential curl git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev
RUN  sudo apt-get -y install redis-server
RUN  sudo apt-get -y install libsasl2-2
RUN  sudo apt-get -y install gnutls-bin
RUN sudo apt-get -y install mutt
RUN sudo apt-get -y install git-all
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
RUN sudo apt-get -y install nodejs
RUN sudo apt-get -y install nano
RUN sudo mkdir -p /.mutt/cache
RUN git clone https://github.com/typpo/textbelt
RUN npm --prefix ./textbelt install ./textbelt
RUN touch ~/.muttrc
RUN echo '"account-hook imap://gmail/ "' >>  ~/.muttrc
RUN echo 'set from = "[email protected]"'>>  ~/.muttrc
RUN echo 'set realname = "yourusername"' >>  ~/.muttrc
RUN echo 'set imap_user = "[email protected]"'  >>  ~/.muttrc
RUN echo 'set imap_pass = "yourpassword"'  >>  ~/.muttrc
RUN echo 'set folder = "imaps://imap.gmail.com:993"'  >>  ~/.muttrc
RUN echo 'set spoolfile = "+INBOX"'  >>  ~/.muttrc
RUN echo 'set postponed ="+[Gmail]/Drafts"'  >>  ~/.muttrc
RUN echo 'set header_cache =~/.mutt/cache/headers'  >>  ~/.muttrc
RUN echo 'set message_cachedir =~/.mutt/cache/bodies'  >>  ~/.muttrc
RUN echo 'set certificate_file =~/.mutt/certificates'  >>  ~/.muttrc
RUN echo 'set smtp_url = "smtp://[email protected]@smtp.gmail.com:587/"'  >>  ~/.muttrc
RUN echo 'set smtp_pass = "yourpassword"'  >> ~/.muttrc
RUN echo 'set move = no'  >>  ~/.muttrc
RUN echo 'set imap_keepalive = 900"'  >> ~/.muttrc

Afterwards, I logged into it:

docker run -it -p 127.0.0.1:80:9090/tcp byshiny/textbelt:version1 bash
#this means that bind port 8080 of the container to 127.0.0.1 of the
#host machine.
#refer to: https://docs.docker.com/engine/reference/commandline/run/#add-bind-mounts-or-volumes-using-the---mount-flag

Clone the git repository:

git clone https://github.com/typpo/textbelt
cd textbelt
npm install

Start the redis server in the background

redis-server --daemonize yes

Create the torlist to avoid textbelt errors

touch server/torlist

Setup a mutt configuration stuff(already did this in the Dockerfile)

#create cache file? Not sure if this was needed
sudo mkdir -p /.mutt/cache
nano ~/.muttrc

account-hook imap://gmail/ “set
set from = "[email protected]"
set realname = "yourusername"
set imap_user = "[email protected]"
set imap_pass = "yourpassword"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates
set smtp_url = "smtp://[email protected]@smtp.gmail.com:587/"
set smtp_pass = "yourpassword"
set move = no
set imap_keepalive = 900

So at this point, you should encrypt this password. I haven’t gotten around to it yet, but you should…

Go into the directory and run the server in the background

cd textbelt
nodejs server/app.js &

Now this is the most exciting part. You can run the command to send yourself a text message! Something like this:


#this is in the actual container
curl -X POST http://127.0.0.1:9090/text --data-urlencode number='18001337 carrier=att' --data-urlencode 'message=Hello world'
txting phone your-number : Hello world

#if you want to publish from outside the Containers
curl -X POST http://127.0.0.1:80/text --data-urlencode number='18001337 carrier=att' --data-urlencode 'message=Hello world'
txting phone your-number: Hello world

And finally we get this:

alt text

And lastly, save the version of the image for your future use:

docker commit c3f279d17e0a  byshiny/textbelt:version1

Been Too Long Since the First Time

One thing I’d like to note on these Algorithm textbooks is that, for whoever writes them, it’s been so long since they’ve first learned the subject, that it’s so easy to gloss over the details. For some of these books, they write the mathematics, and like to gloss over the details without going into further explanation.

When this happens, I wonder if I’m just dumb, or if the authors have become so immersed in their field of study that what seems not as intuitive for the first time learner is super-intuitive for the expect.

But then again, I remember having a similar experience. From a teaching end. I was tutoring this girl in 8th grade math. At this point, I had to explain something like the equation of a line. I’ve seen it so much that it’s become nothing less than second nature to me. Needless to say, I had a hard time explaining something like this because it became so intuitive to me.

How can we fix this???

I think what we can do is write up, and perhaps have people who are learning the subject write about what things that they found confusing, and how they would restructure the text to make it more clear.

Before they too get sucked in, and what they first thought to be so confusing becomes something akin to second nature…

Setting up Portforwarding and SSH From Home Computer

TODO: https://websiteforstudents.com/setup-ssh-server-key-authentication-ubuntu-17-04-17-10/ sudo systemctl enable ssh

Restarting the server….

Auto-startup

Testing on a remote machine…

Jupyter

http://amber-md.github.io/pytraj/latest/tutorials/remote_jupyter_notebook

#DogX_model.add(Dense(10000)) DogX_model.add(GlobalAveragePooling2D(input_shape=train_DogX.shape[1:])) DogX_model.add(Dense(1000, activation = ‘relu’)) DogX_model.add(Dropout(0.3)) DogX_model.add(Dense(500, activation = ‘relu’)) DogX_model.add(Dropout(0.1)) DogX_model.add(Dense(133, activation = ‘softmax’))

A Matter of Perspective

One of the most frustrating things about coding is that it only takes one { to break everything.

Put this { in any random file, and there is a good chance that it will screw everything up. An extra > in an xml file. Recently I had to deal with blank spaces causing havoc.

It’s pretty maddening. Sometimes, you randomly put that extra squiggly due to a typo, etc. Whatever it is, it just breaks everything. Now your code won’t run.

You can dig yourself into a pretty deep hole by not following the most fundamental rule of coding - code a little, test a little. Essentially what this rule is that you must always verify that the code that you wrote is functional and things are working before proceeding any further. So a tiny mistake can be incredibly complicated if you don’t stop yourself and check yourself.

Tangent: I remember a guide on coding a few years back by one of the smartest classmates I know. He emphasized that this verify as you go approach is one of the most fundamental things you can do.

This is very true. In some sense, this could apply to many things in life. Test the waters. Even in the sense of walking. You don’t walk by moving two feet simultaneously. You always proceed with grounding one foot forward before lifting the other one to take another step…

Anyhow, for the longest time I could only see frustration in the fragility of code. Make one mistake, and the whole house will crumble.

But today, I realized the other way of looking at this issue. Every single line of code must be exactly correct. Isn’t there some beauty in this?

In writing, if you screw up the spelling of the word, then the person can still read it. In a building, if you drill a hole in one of the bricks, the building’s not going to crumble. But I feel that the standard for code to run is even higher.

Every line of code must be syntactically correct. Every line of code, if replaced, must reproduce the exact behavior has it has done before, and every single character must adhere to a structured format.

I think there’s a sense of awe in knowing that whatever you’re coding, it has gone through a rigorous vetting process to ensure that every character obeys the rules of the language and conforms to the designed structure.

To top it all off, you know when you see pretty code.

Site built with http://lanyon.getpoole.com/ template. Thanks to @mdo for the original template!