Skip to content

Instantly share code, notes, and snippets.

View LairdStreak's full-sized avatar
🏪
At the office

Laird Streak LairdStreak

🏪
At the office
View GitHub Profile
@LairdStreak
LairdStreak / flask.py
Created September 3, 2020 02:56 — forked from commadelimited/flask.py
Multiple Flask URL routes on a single method
@course.route('/courses/<slug>_<id>/print/')
@course.route('/courses/<slug>_<id>/')
def show_course(slug=None, id=None):
# how do I know whether /print was used, or just normal?
pass
@LairdStreak
LairdStreak / python_tuples.py
Created March 19, 2019 23:10 — forked from ShyamaSankar/python_tuples.py
Cheat sheet for Python tuples
#### Tuple creation #####
# Create a tuple, also called tuple packing.
numbers = 1, 2
print(numbers) # Output: (1, 2) <- Note that it is represented with an enclosing paranthesis
# Create tuple with paranthesis.
numbers = (1, 2, 3)
print(numbers) # Output: (1, 2, 3)
# Create an empty tuple.
numbers = ()
print(numbers) # Output: ()
import PySimpleGUI as sg
layout = [ [sg.Text('Drawing on a 400x400 Grid')],
[sg.Graph((400,400), (0,0), (400,400), key='GRAPH')],
[sg.Button('Go')]
]
window = sg.Window('My new window').Layout(layout)
graph = window.Element('GRAPH')
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""This module's docstring summary line.
This is a multi-line docstring. Paragraphs are separated with blank lines.
Lines conform to 79-column limit.
Module and packages names should be short, lower_case_with_underscores.
Notice that this in not PEP8-cheatsheet.py
@LairdStreak
LairdStreak / flask_matplotlib.py
Created November 8, 2018 20:44 — forked from illume/flask_matplotlib.py
Shows how to use flask and matplotlib together.
""" Shows how to use flask and matplotlib together.
Shows SVG, and png.
The SVG is easier to style with CSS, and hook JS events to in browser.
python3 -m venv venv
. ./venv/bin/activate
pip install flask matplotlib
python flask_matplotlib.py
"""
@LairdStreak
LairdStreak / mock_requests.py
Created November 6, 2018 20:44 — forked from evansde77/mock_requests.py
Example of mocking requests calls
#!/usr/bin/env python
"""
mocking requests calls
"""
import mock
import unittest
import requests
from requests.exceptions import HTTPError