Skip to content

Instantly share code, notes, and snippets.

# Hire person
# Hire other person
# print all employees
# fire person
# pay person (that wasn't fired)
# print all employees
from dataclasses import dataclass
@dataclass
class Person:
first_name: str
# Hire person
# Hire other person
# print all employees
# fire person
# pay person (that wasn't fired)
# print all employees
def create_person(first_name: str, last_name: str, routing_number: int | None = None,
account_number: int | None = None):
return {
@Back2Basics
Back2Basics / graphs_with_networkx.ipynb
Created November 23, 2019 09:35
A truly terrible Idea #2- (demonstrating a NetworkX tutorial)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Back2Basics
Back2Basics / readit.py
Created October 2, 2019 08:04
have your mac read filtered text
# this was used in the youtube clip
data = “”” <paste data here> “””
read_this = [line.partition(‘\xa0’)[2] for line in data.split(‘\n’)]
import subprocess as sp
sp.call([‘say’, ‘ ‘.join(read_this)])
@Back2Basics
Back2Basics / sliding_window.py
Last active May 22, 2019 07:20
n_things at a time
from collections import deque, Counter
from typing import Iterable, Callable
def sliding_window(someiterable: Iterable, n: int, returnable: Callable = ''.join):
"""
generates an n element sliding window one element
at a time in whatever type you want returned
returnable could be tuple or list
"""
n_things = deque()
@Back2Basics
Back2Basics / sets.ipynb
Created November 17, 2016 05:46
Python Sets
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Back2Basics
Back2Basics / Context Manager.ipynb
Created October 20, 2016 19:08
Context Mangers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Back2Basics
Back2Basics / deep_eq.py py3.x
Last active March 7, 2017 09:29 — forked from samuraisam/deep_eq.py
Deep Equality Test for Nested Python Structures
# Copyright (c) 2010-2013 Samuel Sutch [samuel.sutch@gmail.com]
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in

Keybase proof

I hereby claim:

  • I am Back2Basics on github.
  • I am back2basics (https://keybase.io/back2basics) on keybase.
  • I have a public key whose fingerprint is E00C 4FA6 2288 F2C4 21D5 CCA4 158D D0A0 44B8 C5AA

To claim this, I am signing this object:

@Back2Basics
Back2Basics / get_data
Last active January 4, 2016 18:59
webserver
from multiprocessing import Process
import webbrowser as wb
def shutdown_server():
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
func()
def webserver():