Sunday, June 26, 2016

End of programmerdays

This blog has moved to https://programmerdays.com

As of now, I will stop posting to this website.

Saturday, June 18, 2016

Paid to exercise

We live in a weird world. Recently, I've been getting paid to exercise.

My company has partnered with another company called Jiff. After I registered my fitbit account to Jiff, Jiff gives me points based on how many steps I take and how much I sleep. I can then redeem those points for prepaid cards or I can enter raffles.

Here are some numbers for you:

  • 600 points will give you a $20 gift card.
  • 50 points will give you a raffle ticket for things like an ipad mini or a new fitbit.

For the last few months, I have gotten around 500 points per month. It could be a little bit higher if 1) I always remembered to wear my fitbit and 2) I entered things into a food log (which I always forget to do). All in all, it takes me a little over a month to make $20.

So far, I've entered a couple of raffles (but haven't won anything yet) and I have gotten 1 visa prepaid debit card.

I had a little trouble using the virtual $20 prepaid card. First, I wanted to use it with iTalki. But I found out that there is a processing fee. If I used it there, I'd have a remaining balance, and then I'd be stuck trying to figure out how to spend the leftover balance. Then I tried to buy some credits for my digital ocean account. For some reason, the charge was rejected. Finally, I successfully was able to spend it all on credits for indoor hoops.

It is fitting that I was able to use money generated from my fitness activities to do more exercise.

Wednesday, June 15, 2016

Fitbit is a good company

The band on my fitbit Charge HR somehow got an air bubble. Soon after the seams started to become unglued. I was afraid that the band might get caught on something and rip apart at any moment.

So, I went to the fitbit forums and found that others were experiencing the same issue. I sent an email to fitbit with a picture and a description of my problem. They replied within a couple of hours asking for my order number and mailing address. Before I knew it, a replacement fitbit was being prepared for me, and it arrived a few days later.

I am very impressed by fitbit's customer service. Some companies seem to operate by trying to squeeze every penny out of you (t.v. cable companies, airlines, etc ...) In contrast, my interactions with fitbit have all been easy and reasonable.

I don't remember if I mentioned this before, but since I'm talking about my fitbit, here are the things I most use the fitbit for:

  • using it as a silent alarm to wake me up before my wife
  • checking the time
  • checking my historical resting heart rate
  • using it as a reminder to never be too lazy

Saturday, June 11, 2016

Nginx Gunicorn Flask stack

I followed this wonderful guide to set up my flask + gunicorn + nginx application jjjdddfff.com on digital ocean. If you want to do the same, you should probably go there. Here are some additional notes that I took for myself.

What is the stack made of?

nginx is your http server. You tell the nginx server what port to listen to and where to pass requests. It can handle some requests on its own, like serving static resources like images, or redirects from one url to another. If it doesn't handle a request on its own, it can pass it to your app server, which in my case is gunicorn.

gunicorn is your python app server. It translates http requests into wsgi (web server gateway interface) compatible requests, which are forwarded to whatever will process the request.

flask is a python web framework. It will contain all the business logic of creating a response for a given request.

An alternative stack might be something like apache/uWsgi/django. Because it's all new to me, so I can't say with any authority which is better. I just needed to start somewhere, and after googling/reading a bit, I settled on this stack. At the worst, I think all of the pieces are plug and play. If I am unhappy with any piece of the puzzle, I don't think it will be too much trouble to switch out pieces of the stack. Right?

What do you need to do

You should look to the guide for the explicit steps, but I think it boils down to the following. First, install the software you need (nginx and virtualenv) and then within a virtual envinronment (gunicorn and flask). Then you need to write a couple of scripts.

Configure a web server (nginx)

In script, /etc/nginx/sites-enabled/homepage, I set up my web server (nginx) to listen to http requests and pass them to our app server (gunicorn) via a sock file.

server {
    listen 80;
    server_name jjjdddfff.com;

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/username/homepage/homepage.sock;
    }
}
server {
    server_name www.jjjdddfff.com;
    return 301 $scheme://jjjdddfff.com$request_uri;
}

Set up application server (gunicorn)

In script /etc/init/homepage.conf, I created an upstart file that tells ubuntu to start your web application (homepage) that is bound to that "sock" file used in the web server.

description "Gunicorn application server running homepage"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
setuid username
setgid www-data

script
    cd /home/username/homepage
    . venv/bin/activate
    gunicorn --workers 1 --bind unix:homepage.sock -m 007 homepage
end script

Create a web application (flask)

In script, /home/username/homepage/homepage.py, I set up a flask application which will handle all the business logic of processing requests.

from flask import Flask
application = Flask(__name__)

@application.route("/")
def home():
    return "Hello world"

if __name__ == "__main__":
    application.run(host='0.0.0.0')

Some helpful commands

Test the web server.

sudo nginx -t
sudo service nginx restart

Test the application server.

sudo stop homepage
sudo start homepage

Tuesday, June 7, 2016

Indoor Hoops

I had my first experience playing basketball with Indoorhoops.com.

I first signed up for a game a couple of weeks ago, on the Sunday of Mother's day, but there weren't enough people, and the scheduled game was cancelled.

I tried again, and this time there were enough people, and I got to play. I haven't played full court basketball in a couple of years, so I was a little bit nervous whether I could keep up. In the end, I think my skill level was just fine. I'm not sure where I would rank among all the players there, but the team I played on won a few games, and I contributed to those wins somewhat. Basically, I didn't stick out like a sore thumb of incompetence, so that was good.

I think there were about 12 people for a 5v5 game. The winner stayed on, and if you lost, you had a pretty decent chance of getting in the next game, just by hitting some free throws. I think I played for about an hour and half straight, before I volunteered to sit one out.

It was a hot day, and the court was hot too. This was OK with me, and probably helped me get a good workout. The court I went to was a bit small, which was Ok as well, because I probably would've gotten tired faster if it were bigger.

It was a good experience, and I plan on doing it again.

If you want to try it out, consider using this link: https://indoorhoops.com/in/refer/CNFJN12678, so that I can get some referral credits.

Sunday, June 5, 2016

My Virtual Private Server

I bought a server

As a professional computer programmer I have written and deployed a lot of code. Almost all of this code has run on machines that someone else had set up for me. This is a gap of knowledge and understanding and experience that I want to shrink.

This weekend, I made a step towards reducing my knowledge gap by purchasing access to a VPS (virtual private server) from Digital Ocean. With it, I can now start up a linux server "in the cloud" in a couple of minutes. I didn't and don't fully understand what that meant (because of my previously noted knowledge gap), but I signed up for an account and bought some credits anyway.

What did I buy?

I bought something that Digital Ocean calls 'droplets'. Droplets are a virtual server that has an operating system, like Ubuntu, and a set of resources like a hard drive, RAM, bandwidth and an IP address. You can then connect to your droplet via ssh and do whatever unix stuff you like.

I bought the cheapest one which is an Ubuntu server with 512 MB of RAM, 20 GB hard disk and 1000 GB of transfer. It costs $5/month or .007 cents per hour. I used a coupon code, for $10, so I won't start paying for a little while.

For now, I'm still in the process of configuring it. Until I have something like a web server running on it, I have been shutting down the server whenever I am not actively working on it. I think this will save me some cents.

Oh yeah, like I said, I'm a dummy - so without understanding things, I also bought a domain name from google domains. It's jjjdddfff.com. I'm still learning how the server works, so getting a domain name is a bit premature, and money not well spent. Oh well, I guess it'll be motivation to get something working sooner than later.

What have I done so far

So far, I've followed some of digital ocean's tutorials and done the basics. I used ssh to connect to my virtual server from my home machine. I added a non root unix user that has sudo privileges. I added some firewalls.

Next, I plan on installing components for a web stack. And after that, who knows?

Spending Spree

Within the last couple of days, I have been on a spending spree. I bought:

There are so many free options on the internet, so I have always been reluctant to pay for anything. In the past, I've read and used resources right up to the pay wall, and then I go try something else. This strategy works. You can learn and improve in a lot of ways.

But recently I feel like I've hit the point of diminishing returns. I also see now that time is more scarce than dollars. So, I've decided to cross the pay wall for a few items.

I'll write some more details on each of the things I'm now paying for later.

Monday, May 30, 2016

Android MVP Architecture

On the never-ending journey to go from hobby programmer to professional, I am always on the lookout for good programming practices. A couple of weeks ago, I found a sample Android TODO app from Google. This app was created to demonstrate how one might organize and architect an Android application. In this post, I'll discuss what I learned from this project.

Android environment

I haven't done any Android programming in a while, so I had to spend some time getting my Android Studio, the SDK and other things up to date. After a few rounds of downloads, updating and restarting, I was ready to work.

I read that that the new version of Android Studio had some big improvements in emulator performance, but I didn't really notice much difference - things are still bad. On both the emulator and on a real phone, I ran the app without any issue. But the emulator performed terribly with the instrumentation tests. First, some of the tests failed only on my emulator. Second, the emulator took about 20 minutes to run all tests, whereas the phone took about 2 minutes.

It looks like I can do some developing with the emulator, but given my set up, it's still not really a viable solution. For now, I'll just move on.

File organization

When you build projects with Android Studio, it creates some folders and files for you. The top level of the todo app looks like this:

app/
build/
build.gradle
gradle/
gradle.properties
gradlew
gradle.bat
local.properties
settings.gradle
todoapp.imp

and that is pretty similar to all Android apps that I've created in Android Studio.

The major difference I see in this sample apps and ones that I have worked on is that there are a lot more src folders:

app/src/androidTest
app/src/androidTestMock
app/src/main
app/src/mock
app/src/prod
app/src/test

The main/ folder holds most of the code that is used in the app. It will be used in all build variants and flavors.

There are two product flavors listed in app/build.gradle, mock and prod, which correspond to two of the src folders. They both have files that define a class called Injection. This is a little interesting and new for me. The prod and mock versions of this class do the same thing except the mock uses a faked class, which is also defined in the mock directory hierarchy. So, depending on whether we are building a mock or prod version of the app, we will use real or faked classes.

This leaves three test folders androidTest, androidTestMock, and test. Based on the comments (I think): test defines unit tests; androidTest defines integration tests; and androidTestMock defined integration tests that use mock classes. I found this naming to be a little confusing at first, but I think I get it now -- since android is the instrument we're using, androidTest == instrumentTest.

Now that I have a handle on the file organization, I'll look at some code.

Model view presenters

This todo app is implemented using a Model-View-Presenter (MVP) architecture.

In android, things start in an Activity class, and it creates each part of the MVP app. For example:

  • TasksActivity is an AppCompatActivity
  • TasksActivity creates a TasksFragment which is the View
  • TasksActivity creates a TasksPresenter which is the Presenter
  • TasksActivity creates a TasksRepository which gives access to Task objects which is the Model

The Presenter is constructed with references to the Model and the View.

mTasksPresenter = new TasksPresenter(
  Injection.provideTasksRepository(getApplicationContext()),
  tasksFragment);

and the view is aware of the presenter, like so:

public TasksPresenter(  
    @NonNull TasksRepository tasksRepository,   
    @NonNull TasksContract.View tasksView) {  
  ...
  mTasksView.setPresenter(this);
}

This pattern is done for each of the different Activity's. Data from models are processed by the Presenter to be rendered by the View. Conversely, updates from a user can be sent through the View to the Presenter onto the Model.

Conclusion

This sample app is nicely organized and it's something I can emulate in my projects.

Sunday, May 15, 2016

End of Algorithms 2

After falling a bit behind schedule, I am almost finished with Algorithms II from Coursera. I have finished all of the prgramming assignments and all of the lectures. All that remain is the final round of exercises.

Like many worthwhile pursuits, I am glad that I went through the classes (both Algorithms I and II), and also happy that it is over.

There were a lot of things I think I gained from the experience. It gave me a good survey of lots of data structures and algorithms. I wanted to fill-in holes in my knowledge of algorithms, and I think that these courses have done just that. For all of the more advanced subjects, I need to take deeper dives, but I am happy that I have a good breadth of knowledge at least.

Additionally, since Algorithms is taught with Java examples, I got to work with a foreign language and its specific coding style and tool-set. While frustrating at times, it's fun to try new things.

And opposite the 'new', the lecturer shared many interesting historical anecdotes throughout the course. I'm not really big on history, but I think these little tidbits made the material a bit more colorful, which also makes it easier to recall things.

A bit of advice

Now that I am about to finish my second massive online course, I wanted to offer you (and future me) some advice about taking online courses:

  • If you start it, finish it. If you say to yourself, "I'll see how it goes", you will undoubtably quit.
  • Do everything. Watch the lectures, do the exercises, do the projects, participate in forums.
  • Set a time(s) in your day/week to do the work. Schedule it like an appointment that you can't miss.
  • Keep up with the new material and the deadlines (even if they're not really enforced).

What I am saying is, be hard on yourself. Don't let yourself have an excuse for not finishing the course. It's so easy to start and quit.

What's next?

I don't have any plans to take any other Coursera courses in the immediate future. I'll check in again later, but I don't see anything that I'd really want to invest time into for now. So, I don't expect to commit anything else this year.

Luckily, I have a nice backlog of study items that I want to work on. More on that later ...

Tuesday, April 12, 2016

Approach for Studying cppreference.com

My approach for reading the cpp reference materials is to start by reading each of the high level topics (ie each page that is directly linked from the main cppreference landing page. Once I have made a sweep of the high level topics, I'll go back to do more in depth reading of the lower level material.

There is a lot of material, so it is easy to feel overwhelmed. Even the basic concepts page has mentioned many things that I need to review/learn (like translation, parameter packs, and odr-used). I'll have to find the right balance of digging in and challenging myself to really know what I say I know, yet also moving on from a topic so that I don't become bored and frustrated and quit before I should.

I took a quick look at each of those unfamiliar topics I just mentioned and after reading just a little, things weren't nearly as initmidating as before. Translation is just a series of steps to go from the code we type into our text editors to a format that computers can run. Parameter packs are a group of parameters for templates. They are a somewhat newer feature of the C++ language so I don't feel so bad that I don't know them well. And odr-used is an awkward spelling/grammatical phrase describing the concept that things must have unique definitions (unlike declarations).

So this is the start of my cppreference reading journey. Let's see how it goes.

Friday, April 8, 2016

Week 3 of Algorithms Part III. Mincut/Maxflow

I finished the third week's work for Algorithms II from Coursera.

I flew through the lectures and exercises over the weekend. The first set of lectures was on Mincut/Maxflow, and the second set was on Radix sort of strings. It looks like we are wrapping up our work with graphs and restarting work on strings.

I think the mincut/maxcut graph search algorithm is tricky. One example of applying this algorithm is calculating when a baseball team is mathematically eliminated from the playoffs. The programming assignment was based on this baseball problem. It was trivial to complete (we just used an existing API that calculated the maxflow), but it was still hard for me to wrap my head around.

I'll have to review the graph data structure and algorithms more, but it's cool to think that I've learned all the basics. I've always found graph structures to be intimidating. It may be an oversimplification, but here's what I'd say about most graph problems:

- maintain a list of neighbors. 
- do depth first or breadth first search.
- for a given problem, maintain some auxillary data, 
  like previous node or current weight

and that's about it. I should review the material to judge whether that's really an oversimplification or not, but that's what I'm feeling now.

After the mincut/maxflow stuff, the lectures moved to sorting again. Oddly, we studied radix sort, which is rather trivial compared to the more complicated merge/quick/heap sorts. I guess we are transitioning to other string algorithms, so this just a step in that direction.

And now, the course has a break for one week. I will take the week to go over material and the given job interview questions. And, rest.

Sunday, April 3, 2016

Week 2 of Algorithms Part II. MST and Shortest Path

I finished the second week's work for Algorithms II from Coursera.

I had a three day weekend, so I was able to finish the lectures/exercises/programming assignment before the week even started.

We covered Minimum Spanning Trees and Shortest Path algorithms.

For Minimum Spanning Trees, we used Kruskal's algorithm and Prim's Algorithm. I have a hard time remembering what these algorithms refer to. Naming algorithms after a person is nice for that person, but it's a bit pointless. It's like naming a variable in a program after the original coder. It definitely wouldn't pass a code review.

In any case, Prim's algorithm works by doing the following:

Choose a node to start from.
Find the shortest edge that connects it to some other node.
Now, we have a two node component.

Then, repeat the following two steps.
1. From the component, find the shortest edge that connects it to an
   unconnected node.
2. Add that edge and component.

Kruskal's algorithm is a little bit different.

1. Sort the edges from shortest to longest.
2. Choose the shortest edge.
3. Use it if it is making a new connection.
4. Choose the next shortest edge and repeat from step 2.

I think better names for these might be, "NextBestNode" and "NextBestEdge".

Dijkstra's algorithm is an extension of Prim's algorithm where you consider the directions and weights to get the shortest paths.

A key idea in all of these algorithms is to keep building from basic tools. Use things like sorting, priority queues and depth-first or breadth-first iterations, along with some simple arrays for flagging changes and you can come up with some powerful algorithms.

This is demonstrated in the programming assignment. Using a shortest path algorithm with breadth-first searching we're able to do some rather cool image manipulation called seam carving.

This week was fun and cool, but I'll have to go back and review it all so that it really sticks with me moving forward.

Saturday, March 26, 2016

Studying cppreference

I have been writing programs in C++ for several years now, but there are many concepts that I don't know very well. My knowledge of the subject feels so shallow. I want to make a a concerted effort to fill in these holes. So, I'm going to commit to another goal.

I'm going to read each of the references documents in the Standard C++ reference, and then summarize them in my own words.

I like this commitment because it has a well defined ending. I think and hope it will be a worthwhile endeavor.

Update I have heard that the cpluscplus.com website may not be the best reference material to read. It seems like http://en.cppreference.com/w/ may be the more respected source. So, I'll base my studies off of cppreference instead.

See my reports below

Essential Fitness NYC

I went to go work out at Essential Fitness NYC. The trainer (Scott) was very kind and welcoming. I took the "Essential 7" class with two other students, who seem to be regulars at the facility. It was similar to personal training in that the trainer spent a lot of one-one-time with me. We did kettlebell swings, goblet squats, side steps with elastic bands, planks, and some stretching on rollers.

The objective for me to go to this class was to learn to improve my daily home workouts, and I did get some good pointers.

For kettlebell swings, I was instructed to plant my feet firmer into the ground, and to swing faster (my hip hinge should be faster). We also worked on my feet placement a bit (I was encouraged to try a more narrow stance). I'm sure there were a lot of pointers that Scott could have given to me, but he didn't want to overload me with too much information. The advice he gave made sense. If I get my base well grounded, it should help my swing.

For the goblet squat, the trainer gave me one good tip -- lower yourself slowly with control instead of just dropping. This makes squats harder, but probably more effective. I imagine I should do a similar thing for all exercises like push ups and pull ups.

Using the rollers was completely new to me. It seems like something I could get for my apartment, but I'll have to read more before I start shopping for one.

The most challenging thing for me was to get the breathing correct. I've seen and heard others do this coordinated breathing technique before, but I couldn't seem to get it right. I resorted to just taking regular breaths after I 'hissed' or breathed out. This will require more practice.

I think essentialfitnessnyc and Scott are great resources. Before I sign up again, I'd think I'd ask some questions to Scott to see if he thinks I might get more out of his other classes. I wish I could've had more time to work on other movements like the clean, snatch and so on ..., but it's probably the case that I have to learn to walk before I can run.

In my past, from programming to working out to learning anything, I've always favored just learning by myself. I think it was mainly because I was shy (and also broke/cheap). This year, I've forced myself to get some external help, which I hope will help me to improve faster and avoid mistakes. I'm not sure if I will go back to essentialfitnessnyc again, but I think it's good to continue to force myself to go out and get some external help from time to time.

Week 1 of Algorithms Part II. Graphs

I finished Algorithms 1 from Coursera a couple of weeks ago, and this week, I just finished the first weeek's work for Algorithms II from Coursera.

I tried to make the most of my time off between the two classes. I worked on an open source project, did some reading about building web applications and tried to study some other things. During this time off, I realized that I prefer structured classes. They help me to stay focused on the subject of study. With that said, I have to continue to push myself to focus on the material and my deep understanding of it, instead of allowing myself to be satisfied with simply getting the correct answers for the course.

I think some ways to improve my understanding will be to review and participate in the Coursera discussion forums. This gives me a chance to see how others (different from the course instructors) are thinking about the material. In the discussion forum, I can have the chance to approach things as a teacher, which will also help me to understand the material better.

So, onto my thoughts on week 1 of Algorithms 2.

This week, we went over undirected and directed graphs. Using breadth first and depth first searches, we were able to solve some possibly tricky problems like topological sort and finding strong components in directed graphs. The takeaway for me is to get very comfortable with depth and breadth first searches and to have a good mental image of what we get from each. With these two tools you can have a good chance of answering a question. Interestingly, it's a bit difficult to know at first glance how fast you might be able to solve a given problem. It's a lot less intuitive than guessing calculation times of sorting algorithms.

The lectures did an OK job of presenting the material. There were a few demos that you should watch (not just read through). The exercises were rather pain free. They asked you to trace through the steps of things like breadth first and depth first search.

The programming assignment, similar to ones in Algorithm I, asked us to work with existing implementations (this week, a directed graph) instead of writing an implementation on our own. I guess re-writing an implementation on my own can be part of my own self studying. The most time consuming part of this project was understanding the requirements (can there be multiple terms in a synset, is a word unique across synsets, etc ...) After I figured out what the requirements were, it was pretty straightforward to use the provided directed graph class to finish. I'm not sure if it really improved my understanding of Graphs, but at least it didn't take too much time.

Sunday, March 20, 2016

On Knowing

A concept that I will like to internalize is the following:

Know everything about what you say you know. Know a little bit about everything else.

Here are some case studies where this concept comes in handy:

  1. On prioritizing.
    You can devote more time and energy to learning the things you know very deeply. For other things, you can do more leisurely reading and learning.

  2. On working on a project.
    For the parts you know how to build well, you will create a very high caliber product. For parts you don't know well, you will know enough to hire an expert or re-use an existing library that is proven to work well.

  3. On interviews.
    People will often ask you what you know. If you say you know a certain thing, and then they find out that your knowledge in the subject is shallow, you look like a fool. For subjects that you say you don't know, having a general idea is usually sufficient to show that you aren't a one-trick pony. Having this mix of deep and shallow knowledge should prove to the interviewer that you are capable of learning any subject, as it is needed.

Bad interview

I found out about a new position at work and applied for it. I got an interview, but it did not go well.

I heard about the job on one day, did some light Q&A with the team members the next day and then had a technical interview the following day. I wasn't looking for a new job, so I didn't think a technical interview was on my horizon. The interviewer asked if I needed some time, but I thought waiting a day or two would just make me feel more anxious, so I said let's just do it immediately. That was a mistake. A little bit of review would have helped immensely.

The interviewer asked questions about basic things, like object construction and destruction, which I often take for granted when writing code. My focus is often on higher level details, like what would be the next best feature to develop for a client. Reminding myself of the basics would help me on interviews and would also help me write better code.

I also didn't have the right approach for answering questions. For questions that I knew the answer to, I didn't really explain things from first principles well. For questions that I didn't know the answer to, I just admitted I didn't know the answer. I think it would have been better to say something like,

"I don't remember the syntax and rules for this, but if it we assume it worked like this, then we could do this or that."

This would have let the interviewer know that I could think through problems and could move a problem along after googling for minor details. Instead, I allowed myself to get stuck in the mud too many times.

I think the final issue I had was that I simply got tired. I hadn't gone on an interview, or even taken a test, in years. The interview lasted about and 1.5 hours. After about an hour or so of talking, explaining, and thinking, I simply got tired. I felt like giving up on some questions a few times instead of digging deeper and deeper, even if I had more knowledge to share.

I doubt I got the job. That sucks, but that's completely my fault. I think with a little better preparation, I could've done a lot better.

I'm sad that I messed things up, and sad to have to continue on with my current job (I had already begun to daydream about moving on). The positive outcome is that I still have my current job, and learned (the hard way) how to do better on an interview.

Another opportunity will probably arise. I hope I turn this experience into a lesson that improves my interview skills for the next one.

Tuesday, March 15, 2016

First foray into open source with Proselint

For 2016, I challenged myself to contribute to 10 different open source projects on github.

I started looking for a project to work on by scanning through the list of trending github projects. I eventually decided to work on Proselint. The purpose of this project is to develop a tool that could analyze writing - it's a linter for prose.

I want to be a better writer, so a tool to improve my writing would be good to know about and to use. It would also allow me to 'dog-food' software. I like projects where I'm also the user.

Looking through the github page, there were a lot of existing small issues, many of which were tagged 'Easy'. I eventually chose to fix an issue where I would add a check that looks for paragraphs that start with the word 'But'. It seemed like a good balance of an easy problem that I could solve, but not a completely trivial code update.

I eventually made the code change, got my pull request accepted, and became an open source contributer. It was a really small update, but even still, I learned and was reminded of a number of things.

  • pip is a really cool package management program. I should incorporate it into my projects more.
  • regex is powerful. I shouldn't be afraid of it.
  • nosetests is a great way to run tests. I should use this more.
  • I need to figure out a good way to organize files/code better. Having a good structure makes things much easier to find and update.
  • Normally, gvim is my go to text editor, but for this new project Atom with the vim plugin might be a better option. It's much easier to navigate across files and folders and it has some auto-complete to move things along.

This was my first open source contribution adventure, and it was fun, inspirational (for me), and educational. For my next projects, I will look for a variety of projects (different languages, different applications, etc ...). I think the variation will teach me a lot.

As they say, it's certainly better to give than to receive.

Sunday, March 13, 2016

Feynman Method of Learning

I just read about the Feynman method for learning. The article describes it well, so you can read about it here. But in the spirit of the method, I'll try to describe it from memory now.

Start by writing the concept you want to learn at the top of the page.

Example: "How to learn with the Feynman method"
Why: I think this is important for getting you to focus on one concept instead of letting yourself get off tangent.

Describe the concept as if you are teaching it to a beginner.

This means describing the concept without using any subject specific jargon or relying on any other assumptions.

Why: This will expose holes in your understanding.

Go back to the source material.

After you discover holes in your understanding, go back to the source materials (books, lectures, mentors) and re-learn what you are unsure of.

Simplify

Describe the concept again using simpler words and analogies.

Why: This will ensure you have a deep understanding and you aren't accidentally, incorrectly assuming anything.

My takeaway

The methodology sounds good. I think the most important thing is being an active learner, instead of just being a passive observer.

Wednesday, March 9, 2016

Going open source

I have decided to commit to something new.

Before the year ends, I will contribute to 10 different open source projects. That's only about 1 project per month, but it's 10 more than I've ever done before.

I think it will be an interesting challenge. It will force me to be exposed to many new projects, and their unique coding/project styles. I'm sure this exposure will give me new ideas and make me a better developer.

Of course, the other possible benefit is that I'll be contributing to the open source world. Hopefully some good comes out of the that.

Updates
1. March 15 - Created a module for Proselint. See blogpost about it.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Sunday, March 6, 2016

Making peanut butter

I am trying to cook more. It's healthier, and it saves money.

For this winter, I made a few batches of chicken soup from scratch. I also learned to make some Kim chi jigae, which is the most common stew/soup in Korea. I'm pretty happy that I know hot to make these.

Today, I tried something else. I made 3 (small) jars of peanut butter. It's pretty simple to make. I did the following:

  • peel the peanuts (this is the most time consuming part)
  • roast the peanuts for 10 minutes at 350 degrees
  • add a teaspoon of salt and honey
  • blend until it is peanut butter

The hardest part of the process was that my blender kept getting clogged up. I had to do a lot of manual mixing to get the blender to work.

So, that's how this programmer spent part of his morning.

I am not sure if the effort is worth it, so I am not sure if I'll do it again. I wonder what I should try to make next.

Saturday, March 5, 2016

How to Master Skills

Recently, I watched a youtube video from Tim Ferris on how to master any skill.

He describes his process via an acronym called DiSSS:

  • Deconstruct (break the problem down)
  • Select (think 80/20)
  • Sequence (deviating from traditional order might be faster)
  • Stakes (create incentives for success or failure)
  • Simplify (less is more)

I had trouble remembering this acronym because there are too many 'S's. I thought of a better acronym that's easier for me to remember, which is DEQUE.

  • Deconstruct. Same as before.
  • Eighty/twenty. Replacing 'Select' with 'Eighty' gives me a nice vowel for my acronym.
  • Queer. I could be wrong, but when Tim suggests learning things out of sequence, I think he's actually suggesting to us to not be afraid of learning things in a seemingly odd or 'queer' way.
  • Uh-oh. Instead of 'Stakes', I think 'Uh-oh' captures the sentiment of "I need to learn this skill or else I'm screwed."
  • Enough. I think 'Simplify' is fine, but using 'Enough' makes my acronym flow a little better (in my opinion).

Unfortunately, another acronym already exists for deque (double-ended queue), but I still find it easier to remember than DiSSS.

Whichever acronym you go with, the more important part is applying it to the skill you want to learn, and it hopefully helping you master it. That is still to be determined for me.

Thursday, March 3, 2016

Week 6 of algorithms part 1. Hash table and final exam

The sixth and final week of my coursera algorithms course is done.

This week, we had lectures on hash tables, a set of exercises and a final exam. This was a little different from previous weeks where we would have a little bit more lecture material, two sets of exercises and a programming assignment.

The final exam had a lot of tricky questions, where the major obstacle was just reading the question correctly. I started it a few days ago, and didn't submit until today. Every day, after work, I read over the questions and answers to see if I might have been confused about anything.

I ended up getting an OK score, 9.13 out of 10. I can attempt it a couple of more times, but I don't think there's much point in trying to improve the score. It doesn't really mean anything, and I probably wouldn't learn much by doing it again.

It feels good to be done with this. It's great to finish anything, and this is something I wanted to try and finish years ago.

I signed up for part 2 of this course. After which, I hope to be well versed in all the basic data structures and algorithms that every software developer should know.

The next course starts in 2 weeks, so I'll have a little bit of a break, which is nice. Maybe I'll plan what I want to work on after part 2 of this is done - take another course? study some other way? reallocate time to something else?

Saturday, February 27, 2016

Korean language status

For basically my whole life, I wished I could speak Korean better.

I want to speak Korean because most of my extended family, except for some cousins who grew up in America, only speak Korean. Also, I often meet friends of friends who only speak Korean. I think things would be a lot more interesting and easier if I only spoke Korean better.

Furthermore, changes in my immediate family are providing even more motivation to get better at Korean. My retired mom is now spending more and more time in Korea. It would be great to visit her there. I've only ever seen her in America, so I'd love to see her totally comfortable in her mother-land.

My wife has also expressed interest in spending long periods of time going to Korea. As a child, she would spend her summers in Korea - which is why her Korean skills vastly outpaces mine. If we have kids, she's always said that she would like to expose them to both Korean and American culture, and for them to be bilingual.

I've always resisted the idea of spending more time in Korea, in part, because of my weak Korean skills. I think it would be lame of me to deprive my unborn children of a great multi-cultural experience because of my lack of skills. So, it's about time for me to get better at Korean.

In the past, I've done the following things:

  • I listened to Talk to Me in Korean podcasts.
  • I wrote flashcards and studied them with the Anki android app.
  • I tried to watch some Korean movies and dramas on Netflix. Some recent ones were New World and You're all surrounded.
  • Years ago, I also took a class an beginner/intermediate Korean class in college.

but all of these things haven't really gotten me to the fluency level that I'd like.

I think the gigantic ingredient that I am missing from my studies is real conversation practice. To get that practice, I will try out lessons from iTalki. I've signed up for my first lesson with a native Korean speaker. My plan is for my teacher and I to role play (he'll pretend to be my uncle or cousin in law or friend's wife ...), so that I can be exposed to lots of different kinds of situations. I'm really hopeful that this will immensely improve my skills.

iTalki also has a platform where you can write stuff in Korean, and others will comment and correct your writing. I posted something yesterday, and I got a correction in less than a day. It was pretty awesome to get good quick feedback from a native Korean speaker. I think I will take advantage of this more in the future, but I'll have to work on my Hangul (korean alphabet) typing skills. I guess that's just one more thing I have to work to improve on ...

Shameless request time ...

If you do plan on using iTalki it would be awesome if you signed up via this iTalki referral link. Each referral gives me some iTalki points which I can use for lessons. Thank you for your consideration.

Week 5 of algorithms part 1. Red Black Trees

The fifth week of my coursera algorithms course is done.

This was the most interesting week of study for me. We studied balanced binary search trees. I have read about red black trees trees before, but it never really clicked for me. However, the lecture did a great job explaining red black trees by first presenting the related 2-3 tree. This made understanding the red black tree much easier. I am very happy to know this material now.

The exercises were again helpful in pushing me to really understand red black trees. Can you identify if a node should be red or black? Can you make insertions into such a tree? It was a bit painful to write these trees out on paper and trace through the changes, but it's the best way to really show you know it. The exercises had some true/false questions as always, and I got tricked up on them as always. I feel like they are there just to trip you up a few times and make you repeat the exercises a few times before moving on.

This week's programming assignment was my favorite one so far. We actually implemented a KdTree. In some previous assignments we used existing data structures that were presented in class to do something. In this lecture, we were asked to implement the KdTree, which I thought was more interesting and instructive.

I just realized that this is the last programming assignment we will have. This upcoming week, we will have lectures on Hash tables, exercises and then the Final Exam. Hopefully, the exam pushes me to re-think all of the past material and review it so that it really gets engrained in my mind. I have to fight the instinct of trying to just get a good grade, and instead make my goal be getting a good working knowledge of these data structures and algorithms.

Hopefully, I meet that goal.

Saturday, February 20, 2016

Week 4 of algorithms part 1

The fourth week of my coursera algorithms course is done.

We learned about heap sort, binary search trees and priority queues. This is the first week when I feel like I am learning something that I am unfamiliar with. In previous weeks, I had a lot of experience studying and using all of the concepts already.

When I hear a problem, my mind visualizes the data using a few common data structures (maybe a stack/queue/sorted array or list/or a tree). For some reason, I don't immediately think about priority queues. This week's lectures reminded me of the importance and power of them. I think I should go back and review the material one more time to further engrain the concepts.

Because I had a day off this week, I was able to finish all of the material this week with a lot of time to spare.

I look forward to the upcoming week's lessons. In it, we will learn about red/black trees and other balanced search trees. This is one of the holes in my computer science knowledge that I'd really like to eliminate.

Saturday, February 13, 2016

Review

Some good things, some not so good things about me:

Work

Based on feedback from managers and my interactions with colleagues, I think I have been doing good work. Taking a step back, I feel like I have been living scared. I haven't gone on any interviews since I got my job years ago. I should be more active, and less scared of rejection.

Health

I am very pleased with my daily kettlebell training. I feel more fit, but I'm not sure how much. I need to keep better track of what I am doing (ie. how many 1 arm swings/push ups/pull ups/ etc ... per day), so that I can know if I am making progress.

Mental Health

I have pretty much given up meditation. It's boring. I have substituted it with early morning stretching. I am considering waking up about 30 minutes earlier so that I am less rushed in the morning, which may give me more time to meditate.

My dog

I have been trying to find the optimal walking schedule for my dog so that she never has to go in the house. We have cut down her need to use the wee-wee pad from every day and every night to almost never using it at all.

Writing

I have been writing in my private daily journal consistently, but the quality of my writing still feels pretty poor. I'm not sure how I can improve or track my progress.

Learning

I have been keeping up with my coursera course. I am on track to finish the course. This'll be the first one I finished.

Family

Family life has been good. I think I have been better at listening to my wife. I have been communicating more with my brother. My mom is coming back with my brother soon.

Eating

I have some good and bad weeks with respect to cooking and eating. For 90% of my life, I haven't been much of a cook. Recently, I've started making chicken soup from scratch and kim chi jigae (the chicken soup for koreans). I'm eating more salads for lunch. So things are improving.

Korean

I have made little progress. I'm still pretty diligent in doing Anki flash cards. I add four new sentences per day. And, I have been watching a few Korean movies and shows on Netflix. I signed up for an iTalki account so that I can practice speaking. I think this would be the best way to improve, but I haven't committed to doing any sessions.

Other projects

I have pretty much stopped working on any other outside projects. I have used all of my time working on other things like coursera, journaling, etc ..., which I mentioned above.

Week 3 of algorithms part 1

The third week of my coursera algorithms course has just gone by, but I didn't have enough time to finish all of the work.

I started the week OK by completing the lectures and exercises during the weekend. But during the week, I had to go into work early a few times, and I fell behind. I finally submitted the programming assignment this morning. I got a 98.something, with some deductions on performance in one of the test cases. I'd like to get all 100s, but oh well.

This week, we learned about merge sort and quick sort. Even though I was familiar with both of these sorting algorithms before, I think the lectures and exercises really helped me solidify my understanding of both of them.

For me, the most challenging part of the programming assignment was figuring out how to use a "Comparator". That's due to me not being a Java developer. Once again, the programming assignment had very little to do with the lectures or helping me understand sorting algorithms. I don't understand the point of these programming assignments.

This upcoming week, I have an extra day off (President's day) so hopefully, I can go over the previous week's job interview questions and still finish the week's assignments on time.

Sunday, February 7, 2016

Week 2 of algorithms part 1

I have finished the second week of my coursera algorithms course.

Last week, I felt a little bit short on time, so I shifted things around a bit. On the weekend, I completed all lectures and exercises. During the week, I was able to finish the programming assignment in a couple of days and then comfortably go through the job interview questions. Getting the lectures and exercises done on the weekend is the key to me doing the work carefully instead of rushing to the end.

The exercises can be a bit annoying. I often had to do them multiple times because I kept getting one of the true or false questions wrong. On the plus side, it forces you to go through the algorithms carefully a bunch of times.

This week, we learned about stacks, queues and some elementary sorts. As a real programmer, we use these so often without thinking about how they are implemented. It's good to dig into the details every once in a while. Hopefully more complex topics are on the way.

The programming assignment was a little bit more interesting this week. We built data structures that were modified versions of the stacks and queues that we learned about in class. This was better than the previous week where we just used API's that used the data structures discussed in class.

The other thought I had while working through things this week was how nice Java + the eclipse IDE is compared to my normal C++ + vim working environment. On the IDE side of things, the autocomplete is so nice. On the language side, a feature like "Implements" seems much cleaner than in C++. In C++, we'd have to inherit a pure virtual interface class. While logically equivalent, it seems a little bit cleaner in Java. However, that might be a biased opinion, as I am a C++ programmer who is learning Java.

Daily Workouts

I can't remember exactly when, but a while ago, I started doing daily workouts at home. I started with the 7 minute workout and used this app to help me along. I loved the idea of getting in shape at home, for free, and (most importantly) quickly.

After a while, I wanted to increase the intensity, so I started following more intense body weight workouts from youtube. I used youtube videos for a while, but there were some things I didn't like about it. A lot of workouts had me jumping up and down, which I can't really do inside my apartment early each morning. I also wanted to increase the resistance of some movements. So I decided to buy a kettlebell.

After some research, I ordered a beautiful 35 pound kettlebell from Rogue Fitness. With it, I have been doing a daily workout that I have grown to love. Here's my daily workout:

  • 1 Turkish Get Up / side. I use this as my warm up.
  • 30 2 handed swings. I use this to get my heart rate up and to concentrate on getting perfect swinging form.
  • 10 1 handed swings / side. These are still pretty challenging for me, so I try to just do a small number to get my form right.
  • 6 clean + squat + press / side. This combines a bunch of the essential kettlebell movements into one.
  • 6 pull ups.
  • 20 push ups.
  • 15 V ups.
  • 5 single legged sqauts. I can't quite complete these yet without hitting the ground.

This workout gets my heart rate up without me having to jump around in my apartment, and I feel like I'm getting stronger. It takes me about 10 minutes to complete. It would take me longer to commute to any gym than it does for me to finish my entire workout. My wife runs alot, and that takes so much longer (although I do plan on running a bit more on weekends once the weather gets a bit nicer).

As I get used to this workout, I think it will be straightforward for me to make things harder. More reps, new moves, and eventually another (heavier) kettlebell are in my future. Hopefully, this is all working.

Thursday, January 28, 2016

Week 1 of algorithms

I have just finished the first week of the coursera course Algorithms, Part I.

We learned about the union find algorithm and how to do some basic analysis of algorithms. I enjoyed the presentation of the union find algorithm (from an initailly naive implementation to a more robust final solution). The material on analyzing an algorithm is of course important, but a little drier and less fun for me.

The quizzes were helpful in forcing me to work through the gritty details of the lectures again. It often took me about 3 tries for each quiz before I got a perfect score. I think each failed attempt forced me to really think about the material.

I didn't really enjoy the programming assignment this week. Setting up the IDE was a chore. The assignment wasn't really about algorithms. It was more about using an API than understanding algorithms.

One of my worries before starting the course was whether I'd have enough time to do all the work. After one week, I'm still worried. I finished all of the work for this week before the next lecutre comes out tomorrow, but it was close. I didn't have much time to review the optional job interview questions. If the material gets more challenging, I may run out of time. To give myself some more leeway, I think I'll have to cover more material on the weekend.

Sunday, January 24, 2016

Back to School

I have just started the coursera course Algorithms Part 1.

I half-heartedly tried out the course before. I listened to some of the lectures, I glanced through some of the exercises and programming assignments, and I may have tried to do some quickly (using Python instead of Java). But this time, I am going to give it a good effort and do all of the assignments and try to really complete and pass the course.

On Friday, the course began, and I started watching the videos. After the introduction video, I found it easier to just read the lecture notes and the slides. It was quieter and I felt myself concentrating a little bit more. As things get a bit more complex, I may watch the video, especially when there are demos that don't animate in the slides.

By Saturday, I finished the first round of lectures, and I began looking at the programming assignment. Since it's the first assignment, I've been spending a lot of time getting my environment set up. I tried the recommended IDE called Dr Java, but it felt a bit unpolished. I decided to use Eclipse, which I had to re-install. Eclipse is not as light-weight, but I think it makes things a little easier to do, especially since I am a novice Java programmer.

It's a bit annoying getting all of this started. I wish they had set up an initial pre-class assignment before. Before the class started, I could have tried to set things up, and we could have had a simple HelloWorld style project where I could iron out the process of creating files and submitting them. Oh well, once I get this working right, hopefully it won't be so bad in subsequent weeks.

Ok, time for breakfast, and then I will go ahead and give the first week's programming assignment a try.

Thursday, January 21, 2016

5 Days in Cartagena Colombia

We went to Cartagena Colombia for 5 days and 4 nights. You can probably do all of the things we did in a shorter period of time, but we decided to take a very leisurely pace to do everything.

Before I list our days, here are some overall impressions:

The dollar to colombian pesos conversion was especially in our favor. $1 equaled about $3000 pesos. Here are some typical prices of things, converted to United States dollars in the center of the city. Prices could be even cheaper as you go away from the center.
- $1 for a cup of fresh fruit or a beer on the street
- $1-2 Empandas
- $2-3 for a beer in a bar
- $4-5 for a cab from the center of the city to the airport

I felt like the city was the inspiration to the Emerald city in the Wizard of Oz. Emeralds are a big thing in Colombia. They say the best quality emeralds come from Colombia. The center of the city is a walled area which has the nicest neighborhoods. There are lots of very small doors, which reminded me of things that munchkins might use.

My immediate thoughts on Colombia, before going there, is that it is a dangerous place. After going, I think it's pretty safe to be in the city of Cartagena. Now, onto the 5 day itinerary.

Thursday travelled to Cartagena

Uber to JFK. JetBlue to cartagena. Cab 15k pesos to hotel.
Ate chicken empanada, fruit popsicle, and cup of fruit for lunch.
Swam in hotel pool.
Ate at Carmen for dinner. There was a tasting menu, but we didn't go that route. We ended up ordering these items, which were all good: mojito, lemon and coconut rum, Korean taco, crab cake, beef risotto, steak and potatoes. The restaurant also threw in a free appetizer of a fried snail. I think the tastiest dishes was the Korean Taco.

Friday tour of the city

Pancakes and breakfast in room.
Walking tour of fortress, La Popa Monastery, Boca grande beach (just drove by), and an emerald museum. We paid for a private tour which made getting around easier.
Had empenadas with good pesto sauce for lunch. Coffee from Juan valdes and cup of mangoes from street.
Went to pool
Watched sunset on wall at Cafe Del Mar Cartagena. This is probably the best thing to do in Cartagena. We got there about 15-20 minutes before sunset, had a drink and relaxed.
We had dinner at diva pizzeria, which was tasty.
We walked around at night. We probably stayed out until about 10 or so. At that hour, there is still alot of people out walking and a lot of things to see.

Saturday

Relaxing at hotel
Went to pool in morning, read there.
Had lunch at some inexpensive place that served empandas, sandwiches, etc ...
Had Coffee from Cafe San Alberto which was very good.
Went to Clock Inn to watch the Patriots vs Chiefs NFL playoff game. Had burgers and beer.
Walked around the city. There's a lot of action on Saturday night.

Sunday

Rosario Islands with Gente De Mar.
Sat on the beach in the shade and read. Went into the water a little bit.
We had a fish soup, rice, plantains and fish lunch.
City was much quieter on Sundays.
We ended up going back to Diva Pizza for dinner. My wife's stomach was a little upset, so we wanted to get something safe that we knew wouldn't upset things further.

Monday

Aripes for breakfast in hotel.
Did some souvenir shopping, last pictures.
Went to airport. Had a beef empanada which was OK, and a cheese empanda roll which was unbelievably salty and basically inedible.
Flew back to JFK, and uber'd back home.

Tuesday, January 12, 2016

Bugs at Work Messing with My Head

I was debugging an issue yesterday, but I could not fix it.

From the start, I knew the problem failed in an API call written by some other team. I traced through the unfamiliar code stack and determined the problem was that I couldn't write to a given database. But the settings on the machine indicated otherwise. So, it took me all day, and I was still stuck.

Because I couldn't perform at work, I was in a bad mood.

Apologies to my wife. The bug screwed me up.

Update
I subsequently found out that the problem was a deprecated API that was no longer supported in my test environment. It was as if I was trying to figure out why a webpage was rendering poorly on Internet Explorer 6 on a Windows NT machine.

After I discovered this, it just didn't make any sense to try to fix this problem anymore. So, that put an end to my debugging. All in, about 7 hours wasted, but now I could at least move on.

Tuesday, January 5, 2016

End of 2015 review

The end of the year has come so now's a good time to reflect on the past year.

I've really embraced two new ideas/concepts/practices into my approach on life.

The first concept is that every day (whatever I am doing) I am contributing one programmer day's worth of work into my life's work. So whether I am highly productive in building something, or just relaxing with my wife and friends, it's all added to the big tin foil ball of my life. Will it amount to something great? profound? underwhelming? I am not sure. I can only hope and work for today's contribution to be something of significance.

Along with the idea of contributing to my life's work day-by-day, I have embraced a daily routine. It's a simple yet powerful thing. It's something that I critique, review and then follow to make my life better.

So, onto resolutions.

I started the year with one resolution, to finish everything that I start. It's hard to know if that's true, because I've surely finished some things (like my 2nd android app and some DIY home projects) but there's probably countless things that I've left undone. Since my resolution was to finish everything I start, and I'm not sure if I've actually succeeded in doing this resolution, I'll resolve to keep on trying to finish everything I start for 2016 as well. Sounds like I'm in a bit of an infinite loop, but oh well.
Update I just signed up for a coursera course and plan on signing up for another one right after. By the time they are over, half of the year will be gone. I've started and never finished a few of these online courses before, so I resolve to finish at least these two this year.

A second resolution that I'd like to make for myself is to improve my personality. As a science major/engineer/software developer I think I gave myself the excuse that I was good enough socially for an engineer. But as I reflect on the year, I think I've let myself go too much, and that I should work towards being better socially. Similar to physical and mental health, it's not a good idea to not care about my social health at all. I think it will take some effort and uncomfortable-ness, but I hope it will make me a more enjoyable person and help to ground me in stronger relationships as well.

I have a lot of other things that I'd like to improve on (foreign languages, health, computer science skills), but I've already been working on those, so I don't think a new resolution is necessary, but those are still under active development as well.