This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from setuptools import setup | |
| setup( | |
| name='myModuleName', | |
| packages=[ | |
| 'package.moduleA', | |
| 'package.moduleB' | |
| ], | |
| version='0.0.0', | |
| description='description', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # install opencv https://docs.opencv.org/master/d3/d52/tutorial_windows_install.html#tutorial_windows_install_path | |
| # pip install opencv-python | |
| # https://stackoverflow.com/questions/604749/how-do-i-access-my-webcam-in-python | |
| import cv2 | |
| cv2.namedWindow("preview") | |
| vc = cv2.VideoCapture(0) | |
| if vc.isOpened(): # try to get the first frame |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import base64 | |
| import json | |
| import requests | |
| def jupyter_upload(url="http://localhost:8889", | |
| token="280e41422dcdef6fa2ba790279badc019bda0b42f69d53ba", | |
| src="src/test.txt",dst="test2.txt"): | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import hashlib as hasher | |
| from collections import deque | |
| class Block: | |
| def __init__(self, data: str, previous_hash: str): | |
| self.data = data | |
| self.previous_hash = previous_hash | |
| @property |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import smtplib | |
| import email.utils | |
| from email.mime.text import MIMEText | |
| subject = 'subject' | |
| body = '''body | |
| ''' | |
| sender = ('Chen,Chao-Wei', 'willhyper@gmail.com') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| installed = set() | |
| processing = set() | |
| def install(x): | |
| if x in installed:return | |
| if x in processing: raise Exception("cyclic dependency") | |
| processing.add(x) | |
| dependencies = get_dependencies(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| void setByValue(int x) { x = 5; } | |
| void setByReference(int &x) { x = 7; } | |
| void setByPointer(int *x) { *x = 8; } | |
| int main() | |
| { | |
| int x = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // say this code is compiled to test.dll | |
| using System; | |
| namespace Test | |
| { | |
| public class Class1 | |
| { | |
| public static void SetByRef(ref Int32 x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 -m pytest -v test_unittest.py | |
| import unittest | |
| import pytest | |
| xy1 = (1, 2) | |
| xy2 = (3, 4) | |
| @pytest.fixture(scope="class", params=[xy1, xy2]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 -m pytest -v test_fixture.py | |
| import pytest | |
| xy = [(1, 2), (3, 4)] | |
| @pytest.mark.parametrize('x,y', xy) | |
| def test_fixture(x, y): | |
| print('access fixture attributes', x, y) |