分类 程序员 中的文章

从GoogleSheet同步到GoogleCal

这篇主要介绍如何Google sheet里批量创建日历项目并同步到Google calendar的方法。

启发

在本科的时候我就研究了各种办法希望可以快速的创建各种日程,先后尝试过生成csv上传,使用Python API等等,但都比较麻烦。知道了Google sheet可以运行app script就一直想试试。在看了Google官方的博文后,决定实现一下,发现还是比较容易实现的,下面给大家介绍一下。

Step 1:新建脚本

初始表格如下:

……

阅读全文

vscode插件开发

vscode是我日常所使用的编辑器,包括在写这篇文章的时候。在编辑markdown文档的时候,总会遇到插入图片的问题。所以我就想实现一个简单的vscode插件,在运行时,可以将剪贴板里的图片上传到aws s3上之后把文件的url插入到vscode里。这样在写文章的时候就会提高效率。

准备工作

首先确认自己的环境有nodejs和npm,之后安装

  • yeoman
    • npm install -g yo
  • generator-code
    • npm install -g generator-code

实现

首先运行,创建一个新的项目, 选择typescript,之后回答几个问题,就会新建一个项目。

……

阅读全文

python的彩蛋

Total visitor

复活节要到了,美国人有找彩蛋的习俗。我们生活中很多游戏、电影都会隐藏一些东西作为彩蛋,《头号玩家》是一部对于彩蛋文化很好的电影。其实我们天天使用的python也有一个彩蛋。

当你在python的命令行里敲出 import this, 会出现什么?在正常情况下,这个命令是引入一个包,然后就可以利用包里的函数,但是这个特殊的包会打印出python之禅

$ python
Python 3.7.3 (default, Mar 27 2019, 16:54:48) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

虽然我从python2的时代就开始使用python,但之前从来不知道这个彩蛋,当我发现的时候还是惊异不已的。这19条表明了python的设计思路以及在实现遵守的守则。

……

阅读全文