Skip to content

Commit

Permalink
added mentimeter code and minor updates to tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
david-lippert committed May 29, 2024
1 parent b35541b commit 50ab826
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 8 deletions.
55 changes: 47 additions & 8 deletions fire-101/fire-for-lai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {
"editable": true,
"scrolled": true,
Expand All @@ -34,7 +34,39 @@
"import pandas as pd\n",
"import ipywidgets as widgets\n",
"import matplotlib.ticker as mtick\n",
"from IPython.display import YouTubeVideo, display"
"from IPython.display import YouTubeVideo, display\n",
"from helper_functions.mentimeter import Mentimeter"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div style='width:100%; height:40vh;'> <iframe src=https://www.menti.com/alohp2v13yqh height=100% width=30%></iframe><iframe src=https://www.mentimeter.com/app/presentation/al3bon1eofr38siunek3o1ykwqqkf18w height=100% width=69%></iframe> </div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Mentimeter(vote = 'https://www.menti.com/alohp2v13yqh',\n",
" result ='https://www.mentimeter.com/app/presentation/al3bon1eofr38siunek3o1ykwqqkf18w'\n",
" ).show()"
]
},
{
Expand Down Expand Up @@ -491,7 +523,11 @@
" ### How & where to invest (keep it simple)\n",
" * Company investments\n",
" * **401K**\n",
" * **Employee Stock Purchase Plans**\n",
" * Employee Stock Purchase Plans\n",
" * GWU investment options\n",
" * **GW 403(b) Supplemental Retirement Plan**\n",
" * **GW 401(a) Retirement Plan for Faculty and Staff**\n",
" * GW 457(b) Deferred Compensation Plan & GW 457(f) Restoration Plan\n",
" * Online broker (Vanguard, Schwab, Robinhood, etc.)\n",
" * **target age retirement fund**\n",
" * **index funds**\n",
Expand All @@ -504,6 +540,7 @@
"### Free money (Yes you heard that right)\n",
" * Company benefits\n",
" * 401k matching\n",
" * **403(b) with 401(a) funding plus matching**\n",
" * Employee Stock Purchase Plan discounts\n",
" * HSA and other tax free options\n",
"* For advanced users only\n",
Expand Down Expand Up @@ -619,17 +656,19 @@
"- FIRE Intro on Youtube - https://www.youtube.com/watch?v=8si7cqw9wm0\n",
"- FIRE retirement calculator - https://playingwithfire.co/retirementcalculator/\n",
"- Mr. Money Mustache & the 4% Rule - https://www.mrmoneymustache.com/2012/05/29/how-much-do-i-need-for-retirement/\n",
"- compound interest - https://www.fool.com/how-to-invest/thirteen-steps/step-1-change-your-life-with-one-calculation.aspx"
"- compound interest - https://www.fool.com/how-to-invest/thirteen-steps/step-1-change-your-life-with-one-calculation.aspx\n",
"- Was the 401(k) a mistake? - https://www.nytimes.com/2024/05/20/podcasts/the-daily/401k-retirement.html"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": []
"source": [
"## Citations\n",
"Cumby, James & Degiacomi, Matteo & Erastova, Valentina & Guven, Jonna & Hobday, Claire & Mey, Antonia & Pollak, Hannah & Szabla, Rafał. (2023). Course Materials for an Introduction to Data-Driven Chemistry. Journal of Open Source Education. 6. 192. 10.21105/jose.00192. "
]
},
{
"cell_type": "code",
Expand Down
63 changes: 63 additions & 0 deletions fire-101/helper_functions/formatting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""
Functions to produce formatted string output in Jupyter notebooks
"""

__all__ = ['format_pseudocode',
]

__author__ = "James Cumby"
__email__ = "[email protected]"



def format_pseudocode(steps, order):
""" Return pseudocode steps with correct indentation.
Parameters
----------
steps : dict
Dictionary of pseudocode steps with integer keys
order : list
List of integers defining order of steps
"""

indent = 0
shift = -1
output = ''

# for step in order:
# indent += shift
# if (('IF' in steps[step]) or ('FOR' in steps[step])) and shift == 0:
# indent -= 4
# if steps[step][-1] == '.':
# count = 0
# for character in steps[step][::-1]:
# if character != '.':
# break
# else:
# count += 1
# indent -= 4*count
# output += " "*indent + steps[step]+'\n'
# shift = 0
# if ('IF' in steps[step]) or ('FOR' in steps[step]):
# shift = 4
# if ('CONTINUE' in steps[step]):
# shift = -8

for step in order:
output += " "*indent + steps[step]+'\n'
if steps[step][-1] == ':':
indent += 4
elif steps[step][-1] == '.':
count = 0
for character in steps[step][::-1]:
if character != '.':
break
else:
count += 1
indent -= 4*count
if 'CONTINUE' in steps[step]:
indent -= 8

return output
49 changes: 49 additions & 0 deletions fire-101/helper_functions/mentimeter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""
Class to help display mentimeter votes and results within a Jupyter Notebook
"""

__author__ = 'James Cumby'
__email__ = '[email protected]'

__all__ = ['Mentimeter',]

from IPython.display import IFrame, HTML

class Mentimeter():
""" Produce HTML code suitable from mentimeter links"""

def __init__(self, vote=None, result=None):
""" Set up vote and result (display) links. """
self.vote = vote
self.display = result

def _vote_iframe(self):
""" Generate IFrame HTML for voting page. """
if self.vote is not None:
if self.display is not None:
width='30%'
else:
width='70%'
return "<iframe src={} height=100% width={}></iframe>".format(self.vote, width)
else:
return ""

def _display_iframe(self):
""" Generate IFrame HTML for results page. """
if self.display is not None:
if self.vote is not None:
width='69%'
else:
width='90%'
return "<iframe src={} height=100% width={}></iframe>".format(self.display, width)
else:
return ""

def _single_div(self):
""" Combine voting and results iframes (as required) into single div """
return "<div style='width:100%; height:40vh;'> {} </div>".format(self._vote_iframe() + self._display_iframe())

def show(self):
""" Return the ipython HTML object containing the iframes """
return HTML(self._single_div())

0 comments on commit 50ab826

Please sign in to comment.