Skip to content

Instantly share code, notes, and snippets.

@travisluong
travisluong / how-to-build-cli.py
Created December 31, 2021 05:24
How to Build a Command Line Interface Tool with Python, Pandas, Typer, and Tabulate for Data Analysis
import pandas as pd
import psycopg2
import typer
from psycopg2.extras import NamedTupleCursor
from tabulate import tabulate
app = typer.Typer()
conn = psycopg2.connect(
dbname="nfp_boilerplate_dev",

Donut Shop Tutorial

Spoiler Alert!!! If you wish to challenge yourself, please try to complete the assignment without referring to this article. Going through the struggle of trying to get stuff to work and fixing bugs is one of the best ways to learn code. But if you are truly stuck, then go ahead and read this tutorial.

This tutorial will show you how to build a basic "donut shop" website to complete the homework assignment. We will use HTML5, CSS, JavaScript, and jQuery. As with any real world web development projects, requirements can often be vague and open to interpretation. This is just one interpretation of the homework requirements. If what you have so far is different from this, it doesn't mean it's wrong. I would suggest taking the concepts you gain from this tutorial and applying them to what you already have. Please don't copy and paste. If you do go through this tutorial, try to make it fit your original vision of the assignment.

View the completed [webpage](http://projects.travisluong.com/

@travisluong
travisluong / codefellows-f1-hw6.html
Created May 22, 2015 02:45
homework 6 - donut shop
<!DOCTYPE html>
<html>
<head>
<title>Homework 6 - Donut shop</title>
</head>
<body>
<table id="donut-shops" border="1">
<thead>
<tr>
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.
# algorithm for finding first non repeating character
# should be faster than using a O(n^2) nested for loop
class Fnrc
def self.find_fnrc string
characters = Hash.new
position = 0
# O(n)