Skip to content

Instantly share code, notes, and snippets.

:octocat:
Δ

David Wu sudostack

:octocat:
Δ
  • San Francisco
Block or report user

Report or block sudostack

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sudostack
sudostack / poodir-notes.md
Created Jul 19, 2019 — forked from elissonmichael/poodir-notes.md
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz
View poodir-notes.md

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.
View simple_server.py
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./simple_server.py [<port>]
Send a GET request::
curl http://localhost
@sudostack
sudostack / dummy-web-server.py
Created May 19, 2019 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
View dummy-web-server.py
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
View domain_driven_design.md

Domain-driven Design (DDD)

Context mapping

Exercise to help us discover all the concepts living in our organization, and our systems

Get everyone in a room and discover the...

  • Nouns - entities
  • Verbs - events
@sudostack
sudostack / next_permutation.py
Created Jan 16, 2019
Compute next "lexicographical" permutation
View next_permutation.py
def next_permutation(nums):
'''
brute force:
- generate all permutations, loop and find the matching, return the next
- time: O(N^2 * N!) + O(N) [printing/string/char concatenation is the N^2]
procedure:
1. find largest increasing suffix
2. get pivot
3. find pivot's right-most successor in suffix
@sudostack
sudostack / meta.txt
Created Dec 4, 2018
Getting ctrl + f and ctrl + b (meta) on MacOS
View meta.txt
Open iTerm.
Go to iTerm > Preferences... > Profiles > Keys
Under Profile Shortcut Keys, click the + sign.
Type your key shortcut (option-b, option-f, option-d, option-left, etc.)
For Action, choose Send Escape Sequence.
Write b, d or f in the input field.
@sudostack
sudostack / dtp_00.txt
Created Oct 1, 2018
daily technical problem 00
View dtp_00.txt
#0: Given an input, accounts, write a function to produce the given output. Feel free to ask questions
accounts = [
["John", "johnsmith@mail.com", "john00@mail.com"],
["John", "johnnybravo@mail.com"],
["John", "johnsmith@mail.com", "john_newyork@mail.com"],
["Mary", "mary@mail.com"]
]
Output: [
@sudostack
sudostack / randhash.py
Created Sep 28, 2018 — forked from gennad/randhash.py
Generate random hashcode in Python
View randhash.py
import random
random.seed()
hash = random.getrandbits(128)
print "hash value: %016x" % hash
View prefix_trie.py
from collections import deque
class TrieNode:
def __init__(self, char):
self.char = char
self.is_word = False
self.children = {}
class Trie:
def __init__(self):
View djikstra.py
from heapq import *
from collections import *
def djikstra(graph, start, end):
"""
algo:
- bfs with PQ
- track total weight from start to a given vertex
- initialize a table where each weight is infinite, except for the starting vertex (w = 0)
- keep updating the total weight if we encounter a path that is smaller in weight
You can’t perform that action at this time.