This file contains 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 | |
def flatten(t): | |
""" | |
Generator flattening the structure | |
>>> list(flatten([2, [2, "test", (4, 5, [7], [2, [6, 2, 6, [6], 4]], 6)]])) | |
[2, 2, "test", 4, 5, 7, 2, 6, 2, 6, 6, 4, 6] | |
""" | |
from collections.abc import Iterable |
This file contains 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 python2 | |
'''Serving dynamic images with Pandas and matplotlib (using flask).''' | |
import matplotlib | |
matplotlib.use('Agg') | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
from cStringIO import StringIO |
This file contains 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 <string.h> | |
#include <unistd.h> | |
char *moomin[] = { | |
" . ,", | |
"ASCII art (c) Maija Haavisto (@DiamonDie)", | |
"", | |
" \"._.' `' mh/VK", | |
" `. `, `. .'", | |
" . .' `. `' ;", |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
'Emulate max() as fully as possible in pure Python.' | |
# https://stackoverflow.com/questions/69997857/implementation-of-max-function-in-python/69997876#69997876 | |
# https://github.com/python/mypy/issues/7231 | |
from typing import TypeVar, Any, Iterator, Iterable, Optional | |
from typing import Union, Protocol, Callable, cast, Tuple, overload | |
class SupportsGT(Protocol): |
This file contains 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
#+TITLE: Template org-mode document for export to LaTeX/PDF | |
#+AUTHOR: David Weinstein | |
#+LaTeX_HEADER: \usepackage[left=1in,top=1in,right=1in,bottom=1.5in]{geometry} | |
#+LaTeX_HEADER: \usepackage{palatino} | |
#+LaTeX_HEADER: \usepackage{fancyhdr} | |
#+LaTeX_HEADER: \usepackage{sectsty} | |
#+LaTeX_HEADER: \usepackage{engord} | |
#+LaTeX_HEADER: \usepackage{cite} | |
#+LaTeX_HEADER: \usepackage{graphicx} |
This file contains 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 | |
import math | |
# >> Discrete Fourier transform for sampled signals | |
# x [in]: sampled signals, a list of magnitudes (real numbers) | |
# yr [out]: real parts of the sinusoids | |
# yi [out]: imaginary parts of the sinusoids | |
def dft(x): | |
N, yr, yi = len(x), [], [] |
This file contains 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
..:77I777777777777777777777I. . | |
..?77777777777777777777777777777$+.. | |
. ~7777777I7777777777777777777777777$~.. | |
.7I7777...7777777777777777777777777$7+. | |
.?7777.. ..77777777777777777777777$$7. | |
.77777 777777777777777777777$$$$$I | |
.77777.. ...7777777777777777777$$$$$$$$ | |
.7777777 .77$777777777777777777$$$$$$$$ | |
.77777777777777777777777777777$$$$$$$$$$ | |
.77777777777777777777777777$$$$$$$$$$$$$ |
This file contains 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
def linear_complexity(self, bin_data, block_size=500): | |
""" | |
Note that this description is taken from the NIST documentation [1] | |
[1] http://csrc.nist.gov/publications/nistpubs/800-22-rev1a/SP800-22rev1a.pdf | |
The focus of this test is the length of a linear feedback shift register (LFSR). The purpose of this test is to | |
determine whether or not the sequence is complex enough to be considered random. Random sequences are | |
characterized by longer LFSRs. An LFSR that is too short implies non-randomness. | |
:param bin_data: a binary string |
OlderNewer