➜ Accounting ledger --anon --head 10 -f 2021.ledger csv 'Expense:Food' | csvsql -H --query 'SELECT `a`, SUM(`f`) FROM `expense` GROUP BY `a` ORDER BY `a` ASC' --tables 'expense' | tail -n '+2' > /tmp/data.csv ➜ Accounting cat /tmp/plot_expense.gplot set format x '%y-%m-%d' set style data boxes set terminal png font '/System/Library/Fonts/Hiragino Sans GB.ttc' set title '吃的开销' set output '/tmp/xyz.png' set timefmt '%Y-%m-%d' set xdata time set xlabel '日期' set xrange ['2019-09-10':'2019-09-13'] set ylabel '金额(¥)' set yrange [0:200] set datafile separator comma plot '/tmp/data.csv' using 1:2 ➜ Accounting gnuplot /tmp/plot_expense.gplot
➜ Accounting ledger -b '2021-01-01' -f 2021.ledger csv 'Expense:Food' | csvsql -H --query 'SELECT strftime("%W", `a`) AS `week`, SUM(`f`) FROM `expense` GROUP BY `week` ORDER BY `a` ASC' --tables 'expense' | tail -n '+2' > /tmp/expense_dow.csv ➜ Accounting head /tmp/expense_dow.csv 00,633.6 01,437.3 02,337.5 03,428.4 04,191.5 05,330.4 06,154.6 07,621.4 08,485.6 09,375.73
同时也需要调整gnuplot的脚本
1 2 3 4 5 6 7 8 9
set terminal png font '/System/Library/Fonts/Hiragino Sans GB.ttc' set title '吃的开销' set output '/tmp/xyz2.png' set xlabel '第几周' set xrange [0:54] set ylabel '金额(¥)' set yrange [0:1000] set datafile separator comma plot '/tmp/expense_dow.csv' using 1:2 with lines
set terminal png font '/System/Library/Fonts/Hiragino Sans GB.ttc' set title '吃的开销' set output '/tmp/xyz2years.png' set xlabel '第几周' set xrange [0:54] set ylabel '金额(¥)' set yrange [0:1000] set datafile separator comma plot '/tmp/expense_2years.csv' using 1:2 with lines title "2020", '/tmp/expense_2years.csv' using 1:3 with lines title "2021"
读过我以前的文章《当我们git merge的时候到底在merge什么》的朋友们应该都知道,如果一次合并不是fast-forward的,那么会产生一个新的commit类型的对象,并且它有两个父级commit对象。以知名的 Go 语言 Web 框架gin的仓库为例,它的哈希值为e38955615a14e567811e390c87afe705df957f3a的提交是一次合并产生的,这个提交的内容中有两行parent
1 2 3 4 5 6 7 8
➜ gin git:(master) git cat-file -p 'e38955615a14e567811e390c87afe705df957f3a' tree 93e5046e502847a6355ed26223a902b4de2de7c7 parent ad087650e9881c93a19fd8db75a86968aa998cac parent ce26751a5a3ed13e9a6aa010d9a7fa767de91b8c author Javier Provecho Fernandez <javiertitan@gmail.com> 1499534953 +0200 committer Javier Provecho Fernandez <javiertitan@gmail.com> 1499535020 +0200
Merge pull request #520 from 178inaba/travis-import_path
defrun(self): i = 0 while len(self.commits) > 0and i < self.times: commit = self.commits.pop(0)
for parent_id in commit.parents: parent = CommitObject(commit_id=parent_id) self._enqueue(parent)
print('{} {}'.format(commit.commit_id, commit.timestamp)) i += 1
def_enqueue(self, commit: CommitObject): for comm in self.commits: if commit.commit_id == comm.commit_id: return # 插入排序,先找到一个待插入的下标,然后将从i到最后一个元素都往尾部移动,再将新节点插入下标i的位置。 i = 0 while i < len(self.commits): if commit.timestamp > self.commits[i].timestamp: break i += 1 self.commits = self.commits[0:i] + [commit] + self.commits[i:]
曾几何时,Python 程序员还会津津乐道于 Python 之禅中的There should be one-- and preferably only one --obvious way to do it.,但其实 Python 光是在定义一个函数的参数方面就有五花八门的写法了。甚至在写这篇文章的过程中,我才知道原来 Python 的参数列表中可以通过写上/来使其左侧的参数都成为 positional-only 的参数。
Typically the data that crosses the boundaries is simple data structures. You can use basic structs or simple Data Transfer objects if you like. Or the data can simply be arguments in function calls. Or you can pack it into a hashmap, or construct it into an object.
在nest/app/use_case/目录下的所有用例采用的都是这里提到的construct it into an object的方式。以create_task.py为例:
Strictly speaking, business rules are rules or procedures that make or save the business money. Very strictly speaking, these rules would make or save the business money, irrespective of whether they were implemented on a computer. They would make or save money even if they were executed manually.
业务规则往往不是独立存在的,它们需要作用在一些数据上
Critical Business Rules usually require some data to work with. For example, our loan requires a loan balance, an interest rate, and a payment schedule.
但在整洁架构的示意图中,Use Cases层也是有维护规则的,它维护的是应用的业务规则(Application Business Rules)。与Entities层所维护的业务规则不同,Use Cases层的业务规则取决于应用提供的功能。例如,在nest项目修改一个计划的用例ChangePlanUseCase类的方法run中,会:
Also unlike C, expressions like a < b < c have the interpretation that is conventional in mathematics
也就是说,在C语言中要写成a < b && b < c的表达式,在Python中可以写成a < b < c。并且,标准中还提到
Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent to x < y and y <= z, except that y is evaluated only once (but in both cases z is not evaluated at all when x < y is found to be false).