π to 3200 digits in the Library of Babel
The decoding key is as follows:
Character | Digit |
---|---|
a | 0 |
b | 1 |
import re | |
text = "Dummy text here with the cards" | |
# Regex for Basic Card with Extra field using #flashcard | |
basic_regex = r"((?:[^\n][\n]?)+) #flashcard ?\n*((?:\n(?:^.{1,3}$|^.{4}(?<!<!--)(?<!Extra: ).*)))(?:\nExtra: (.*))+" | |
# Regex for Cloze Card with Extra field | |
cloze_extra = r"((?:.+\n)*(?:.*==.*)(?:\n(?:^.{1,6}$|^.{7}(?<!<!--ID:)(?<!Extra: ).*))*)(?:\nExtra: (.*))?" |
import re | |
text = "[hello:: world]\n[key:: value]\n[testing::1]\n[listing::1,2,3]" | |
# Caveat: These regex only work with one field on a line | |
# and cannot have two or more in the same line. | |
key_regex = r"(?!\[).*(?:(?=\:\:))" | |
value_regex = r"(?:(?<=\:\:)(.*)(?=\]))" | |
# Save values to a list |
def round_up(n, decimals=0): | |
# Move significant decimal digits to the left of the decimal point | |
multiplier = 10 ** decimals | |
# Truncate the unneeded digits on the right of the decimal point | |
sig_digits = n * multiplier // 1 | |
# Determine whether to round up or round down | |
# Return 1 if the tenth digit is greater than or equal to 5, | |
# else return 0 if less than 5 |
The decoding key is as follows:
Character | Digit |
---|---|
a | 0 |
b | 1 |
# Script to parse the csv from the Forest App into a pandas dataframe | |
#%% | |
import pandas as pd | |
from datetime import datetime | |
### Specify pattern for dates in Forest's csv export for dateparser | |
dateparse = lambda x: datetime.strptime(x, "%a %b %d %H:%M:%S %Z%z %Y") | |
### Sidenote: Alternative regex patterns |
<!------------------- SITE HEADER --------------------> | |
<!-- KaTeX for math, Use \( \) and \[ \] --> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.css" crossorigin="anonymous"> | |
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.js" crossorigin="anonymous"></script> | |
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script> | |
<!-- Prism.js for code syntax highlighting (header) --> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.26.0/themes/prism-tomorrow.min.css" /> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.26.0/plugins/toolbar/prism-toolbar.min.css" /> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.26.0/plugins/line-numbers/prism-line-numbers.min.css" /> |
# Used in Deepnote | |
!pip install selenium | |
!apt-get update | |
!apt install -y chromium | |
!wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip | |
!unzip chromedriver_linux64.zip | |
!chmod +x chromedriver |