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 python | |
| import base64 | |
| from Crypto import Random | |
| from Crypto.Cipher import AES | |
| BS = 16 | |
| pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS) | |
| unpad = lambda s : s[0:-s[-1]] |
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 | |
| import datetime as date | |
| # Define what a Snakecoin block is | |
| class Block: | |
| def __init__(self, index, timestamp, data, previous_hash): | |
| self.index = index | |
| self.timestamp = timestamp | |
| self.data = data | |
| self.previous_hash = previous_hash |
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 signal | |
| def handler(sig, frame): | |
| print(sig) | |
| raise KeyboardInterrupt | |
| signal.signal(signal.SIGINT, handler) # press Ctrl+C to trigger handler | |
| import sys | |
| if sys.platform == 'win32': |
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 sys | |
| import numpy as np | |
| N = int(sys.argv[1]) | |
| def SSN(N : int): | |
| ss = SS() | |
| ss_true = SS_ground_truth() | |
| for i in range(N): | |
| pos = next(ss) | |
| pos_true = next(ss_true) |
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 click | |
| @click.command() | |
| @click.option('-c','--count', default=1, type=int, help="this is count as int") | |
| @click.option('-n','--name', prompt="name please?", help="this is name as str") | |
| def hello(name, count): | |
| """help message hello somebody""" | |
| for i in range(count): | |
| click.secho(name, fg='green', blink=True, bold=True) |
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
| ''' | |
| when using n samples to estimate population std, | |
| we will put (n-1) in the denominator: | |
| population_std = sqrt( sample_sum_of_err_sq / (n-1)) | |
| i.e., | |
| population_var * (n-1) = sample_sum_of_err_sq |
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) |
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
| // 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
| #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; |
OlderNewer