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
import numpy as np | |
def create_deck(): | |
RANKS = '2 3 4 5 6 7 8 9 10 J Q K A'.split() | |
SUITS = '♣ ♢ ♡ ♠'.split() | |
return np.array([r + s for s in SUITS for r in RANKS]) | |
print(create_deck()) | |
# ['2♣' '3♣' '4♣' '5♣' '6♣' '7♣' '8♣' '9♣' '10♣' 'J♣' 'Q♣' 'K♣' 'A♣' '2♢' | |
# '3♢' '4♢' '5♢' '6♢' '7♢' '8♢' '9♢' '10♢' 'J♢' 'Q♢' 'K♢' 'A♢' '2♡' '3♡' |
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
# Auto-activate virtual environments on cd when it's called `venv/` | |
# auto activate virtualenv | |
# Modified solution based on https://stackoverflow.com/questions/45216663/how-to-automatically-activate-virtualenvs-when-cding-into-a-directory/56309561#56309561 | |
function cd() { | |
builtin cd "$@" | |
## Default path to virtualenv in your projects | |
DEFAULT_ENV_PATH="./venv" | |
## If env folder is found then activate the vitualenv |
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
# How can I make sure that the exception messages | |
# of Exceptions that occur in the sub-function `load_model()` | |
# show up in the stack trace of the `main()` function? | |
class UnsupportedInputError(Exception): pass | |
class SourceEqualsTargetError(Exception): pass | |
supported_inputs = ["a", "b", ...] | |
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
{ | |
"window.zoomLevel": 3, | |
"workbench.startupEditor": "none", | |
"workbench.editorAssociations": { | |
"*.ipynb": "jupyter.notebook.ipynb" | |
}, | |
// remove distracting elements | |
"breadcrumbs.enabled": false, | |
"editor.minimap.enabled": false, | |
"workbench.statusBar.visible": false, |
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 modify_make_command(arguments, project_path, parent_folder, folder, suffix): | |
if arguments == config.benchmark.BENCHMARK["HPCG"].url: | |
for sub_path in Path(project_path.joinpath("apps", parent_folder, folder)): | |
shell_execute(f"make arch={suffix}", sub_path.parent.as_posix()) | |
if arguments == config.benchmark.BENCHMARK["CLOVERLEAF"].url: | |
for sub_path in Path(project_path).glob(f"**/**/?akefile"): | |
shell_execute( | |
"make COMPILER = GNU MPI_COMPILER = gfortran C_MPI_COMPILER = gcc", | |
sub_path.parent.as_posix(), | |
) |
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
print("hellow") |
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
# Requires installation of `ffmpeg` and `ffmpeg-python`: | |
# - https://www.ffmpeg.org | |
# - https://pypi.org/project/ffmpeg-python/ | |
import fractions | |
from pathlib import Path | |
import ffmpeg | |
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
from pathlib import Path | |
import re | |
with open('outline.md', 'r') as f_in: | |
content = f_in.read() | |
# Finds all time mentions in the format shown below | |
pattern = r'\((\d+)\smin\)' # (3 min) | |
minutes = re.findall(pattern, content) |
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
import argparse | |
from pathlib import Path | |
import re | |
import sys | |
my_parser = argparse.ArgumentParser(description='List Markdown headings') | |
my_parser.add_argument('Path', | |
metavar='path', | |
type=str, |
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
import requests | |
from bs4 import BeautifulSoup | |
BASE_URL = "https://codingnomads.github.io/recipes/" | |
def get_page_content(url): | |
"""Gets the response from a HTTP call to the URL.""" | |
page = requests.get(url) | |
return page |
NewerOlder