Skip to content

Instantly share code, notes, and snippets.

View MatthewCaseres's full-sized avatar
😹

Matthew Caseres MatthewCaseres

😹
View GitHub Profile
# run timer
logs = asyncio.run(pom.work())
# format logs
logs = [
(
task,
start.strftime("%m/%d/%Y %H:%M:%S"),
finish.strftime("%m/%d/%Y %H:%M:%S"),
(finish - start).total_seconds()/3600
)
# Load the audio file
with importlib.resources.path(audio, "alarm.wav") as alarmPath:
wave_obj = sa.WaveObject.from_wave_file(str(alarmPath))
# code
# code
# When the work is done play the bell
if not task.finished and task.endTime - task.startTime >= task.workInterval:
wave_obj.play()
# Concurrently listen and display. Return user data when finished.
async def work(self):
await asyncio.gather(self.listen(), self.display())
return [(task.task, task.startTime, task.endTime) for task in self.tasks]
async def listen(self):
while True:
content = await ainput("")
if content == '':
if self.tasks[-1].task != 'break':
self.tasks.append(PomodoroTask('break', self.breakInterval))
else:
self.tasks.append(PomodoroTask(self.task, self.workInterval))
elif content == 'q':
self.finished = True
pom = Pomodoro(
task="open source",
workInterval=timedelta(minutes=30),
breakInterval = timedelta(seconds=5),
goal = timedelta(hours=2))
logs = asyncio.run(pom.work())
@MatthewCaseres
MatthewCaseres / pomodoro.json
Created February 28, 2021 14:57
routine configuration
{
"Open Source": [
{
"activity": "Open Source"
}
],
"morning1": [
{
"activity": "wake up",
"m": 10,
{
"Open-EdTech/mostly-adequate-guide/ch01.md": {
"treePath": [0],
"ghUrl": "https://github.com/Open-EdTech/mostly-adequate-guide/blob/master/ch01.md",
},
"Open-EdTech/mostly-adequate-guide/ch02.md": {
"treePath": [1],
"ghUrl": "https://github.com/Open-EdTech/mostly-adequate-guide/blob/master/ch02.md",
},
//...
import bookTree from '../bookTree.json'
export const getStaticProps = async ({ params }) => {
//traverse the tree to make the metaObject
const metaObject = getAllRoutesInfo(bookTree);
//Turn the id into a string that is a key from allRoutesInfo
const stringRoute = (params!.id).join("/");
//Grab what you need
const {ghUrl, treePath} = metaObject[stringRoute]
//Pass it to the child component
const SideBar = ({ children}) => {
const [mdVisible, setVisible] = useState(true);
return (
<div className="flex">
<div
className={`${mdVisible ? "md:block" : "md:hidden"} ${mdVisible ? "hidden" : "block"}`}
>
<ExitMenu onClick={() => setVisible(mdVisible => !mdVisible)} />
<Menu />
</div>
import Node from "./Node";
const RenderNode = ({node, pagePath}) => {
return (
<div>
<Node node={node} pagePath={pagePath}/>
{node.children && node.open && (
<div
style={{
margin: "2px 0px 2px 12px",