This file contains hidden or 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
| \version "2.20.0" | |
| #(ly:set-option 'midi-extension "mid") | |
| \paper { | |
| #(set-paper-size "letter") | |
| top-margin = 2\cm | |
| left-margin = 2\cm | |
| right-margin = 2\cm | |
| ragged-bottom = ##t |
This file contains hidden or 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
| package main | |
| import "fmt" | |
| func ListToSet[T comparable](list []T) []T { | |
| m := make(map[T]bool) | |
| for _, r := range list { | |
| m[r] = true | |
| } | |
| set := make([]T, 0) |
This file contains hidden or 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 | |
| project_root = Path(__file__).parent.parent | |
| testdata = project_root.joinpath("testdata") | |
| __all__ = [ | |
| 'testdata', | |
| ] |
This file contains hidden or 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 logging | |
| import sys | |
| logging.basicConfig(level=logging.INFO, | |
| format="%(levelname)s %(asctime)s %(module)s:%(lineno)d %(funcName)s() %(message)s", | |
| datefmt="%H:%M:%S") | |
| ch = logging.StreamHandler(stream=sys.stdout) | |
| ch.flush() |
This file contains hidden or 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 logging | |
| from abc import ABC, abstractmethod | |
| class Animal(ABC): | |
| """ Abstract base class for animals """ | |
| @abstractmethod | |
| def saying(self) -> str: | |
| """ What sound does this animal make? """ |
This file contains hidden or 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
| userid = 1 # TODO remove hard-coded userID | |
| query = DBGrid.query.filter_by(userid=userid, gridname=gridname) | |
| oldgrid = query.first() | |
| if oldgrid: | |
| db.session.delete(oldgrid) | |
| db.session.commit() |
This file contains hidden or 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
| # Save the file | |
| userid = 1 # TODO Replace hard coded user id | |
| query = DBGrid.query.filter_by(userid=userid, gridname=gridname) | |
| if not query.all(): | |
| # No grid in the database. This is an insert | |
| logging.debug(f"Inserting grid '{gridname}' into grids table") | |
| created = modified = datetime.now().isoformat() | |
| newgrid = DBGrid(userid=userid, | |
| gridname=gridname, | |
| created=created, |
This file contains hidden or 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
| Yes, YOU CAN RECOVER from a hard reset in git. | |
| Use: | |
| git reflog | |
| to get the identifier of your commit. Then use: | |
| git reset --hard <commit-id-retrieved-using-reflog> | |
| This trick saved my life a couple of times. |
This file contains hidden or 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
| class UndoRedo: | |
| """ Provides coordinated support for undo and redo """ | |
| def __init__(self): | |
| self.current_value = None | |
| self.undo_stack = Stack() | |
| self.redo_stack = Stack() | |
| # Set a new value | |
| def set_value(self, new_value): |
This file contains hidden or 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
| find . -name '__pycache__' | xargs -i rm -rf {} |
NewerOlder