Python Web Scraping Best Practices

I've been scraping the web a lot as part of my quest to find the best scratch-off lottery ticket [https://scratchoff-odds.com]. I want to share some of the practices that I've discovered. I'll do so by posting the code itself in a style of "literate programming [https://en.wikipedia.…

Tmux Config

# C-b is "back 1 char" in emacs # Unbind it as the Tmux prefix to not conflict with emacs unbind-key C-b set-option -g prefix C-] # If we change our .tmux.conf and want to reload it quickly bind r source-file ~/.tmux.conf # Use vim movement keys for moving between panes unbind-key…

Analyzing California State Scratchers

Let's figure out the expected loss of playing scratchers. California publishes all of the information we need to determine this at their website http://www.calottery.com/play/scratchers-games/top-prizes-remaining From there, for each game, we can see: 1. Price of a ticket 2. Value of each prize 3. Odds…

Using Graphviz DOT for UML

Graphviz DOT, UML, and VIM Prerequisites * Graphviz [http://www.graphviz.org/Download..php] * WM Graphviz Vim Plugin [https://github.com/wannesm/wmgraphviz.vim] (Optional) * Grip Github Markdown Previewer [https://github.com/joeyespo/grip] (Optional) Add UML Diagrams to your Github README with Graphviz Install the prereqs. If you would rather…

Hosting a Node.js process on a non-default port on AWS Elastic Beanstalk

Two things happen that make it difficult to run a Node.js process on a non-default port. First, Elastic Beanstalk uses load balancers. When a request hits your EB DNS (your-app.elasticbeanstalk.com) the load balancer directs the traffic to the least utilized instance (assuming you have multiple ec2 instances…

Overriding the 'verify' method on MiniTest::Mock

Ran into an interesting problem today in which a method in one of my classes happened to have the same name as a method on my testing framework. I'm pasting a lot of code but highlighting the important details with comments. Contract require_relative './exceptions' require_relative './fulfillment_…

'New' Keyword in JavaScript

The new operator is often misunderstood and improperly used by programmers just learning JavaScript. This operator "creates an instance of a user-defined object type or of one of the built-in object types that has a constructor function". Let's focus on one part a a time. In the sentence above, "constructor"…

How to check out a GitHub pull request locally

A common git workflow is for developers to work on a feature branch of their local fork and then submit a pull request to the upstream master. The pull request is then reviewed by other members of the team and if everything looks good it's merged in. For simple pull…

Browser extensions to add tab in textarea

Here's a little productivity tip if you do a lot of in-browser text editing. If you ever get annoyed that the tab key moves your cursor to the next form field when you are editing a text-area in a browser, download this Chrome extension. https://chrome.google.com/webstore/detail/…