go

Vim下一键运行python代码

巧了我就是萌 提交于 2021-02-11 19:35:11
根据系统将下面代码复制到vim配置文件vimrc中,即可在vim中一键【F5】运行.py文件。 Windows下的gvim "一键运行代码 function CheckPythonSyntax() let mp = &makeprg let ef = &errorformat let exeFile = expand("%:t") setlocal makeprg=python\ -u set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m silent make % copen " set efm 是设置quickfix的errorformat,以便vim识别 " makeprg 是vim内置的编译命令,可以通过更改来实现编译对应类型文件。具体可参考vim官方说明文件。 " copen是打开quickfix,n用来设置quichfix窗口大小,如 cope5。在错误描述上回车,可以直接跳转到错误行。 let &makeprg = mp let &errorformat = ef endfunction "一个是普通模式下,一个是插入模式下 au filetype python map <f5> :w <cr> :call CheckPythonSyntax() <cr> au filetype

Python 一键转化代码为流程图

早过忘川 提交于 2021-02-11 19:10:28
Graphviz是一个可以对图进行自动布局的绘图工具,由贝尔实验室开源。我们在上次 Python 快速绘制画出漂亮的系统架构图 提到的diagrams,其内部的编排逻辑就用到了这个开源工具包。 而今天我们要介绍的项目,就是基于Python和Graphviz开发的,能将源代码转化为流程图的工具:pycallgraph。 1.准备 开始之前,你要确保Python和pip已经成功安装在电脑上噢,如果没有,请访问这篇文章: 超详细Python安装指南 进行安装。如果你用Python的目的是数据分析,可以直接安装Anaconda: Python数据分析与挖掘好帮手—Anaconda Windows环境下打开Cmd(开始—运行—CMD),苹果系统环境下请打开Terminal(command+空格输入Terminal),准备开始输入命令安装依赖。 当然,我更推荐大家用VSCode编辑器,把本文代码Copy下来,在编辑器下方的终端运行命令安装 依赖模块 ,多舒服的一件事啊: Python 编程的最好搭档—VSCode 详细指南 。 在终端输入以下命令安装我们所需要的依赖模块: pip install pycallgraph 看到 Successfully installed xxx 则说明安装成功。 macOS用户请使用brew安装: brew install graphviz

gin+vue的前后端分离开源项目

倖福魔咒の 提交于 2021-02-11 18:59:49
该项目是gin+vue的前后端分离项目,使用gorm访问MySQL,其中vue前端是使用 vue-element-admin 框架简单实现的; go后台使用jwt,对API接口进行权限控制。此外,Web页面在token过期后的半个小时内,用户再次操作会自动刷新token; 项目很小,适合gin新手学习!(后续有时间会补上相关教程) GitHub地址: https://github.com/Bingjian-Zhu/gin-vue 一、运行go后台项目 (1)把项目clone到GOPATH/src目录下 (2)在MySQL中新建blog数据库,运行文件夹/docs/sql中的mysql.sql脚本 (3)在文件夹/conf中修改配置文件api.ini中的数据库连接配置 (4)在gin-vue目录下运行: go run main.go 目前为止,gin后台项目成功跑起来了 (5)可能遇到的问题 如果在GitHub是用下载压缩包的形式,解压后请把文件夹gin-vue-master重名为gin-vue,然后再复制到/GOPATH/src目录下 二、使用Postman测试API接口 (1)登录,token过期时间设为5分钟 (2)使用token调用API接口 (3)API权限验证 当使用admin登录获取的token调用/api/v1/table/list接口时,能获取到数据

How to show a table from a slice with my struct

こ雲淡風輕ζ 提交于 2021-02-11 18:26:11
问题 I want to show a table that each row contains my struct data. Here is my struct: type My_Struct struct { FIRST_FIELD string SECOND_FIELD string THIED_FIELD string } Here is my html code: <table id="t01"> <tr> <th>FIRST FIELD</th> <th>SECOND FIELD</th> <th>THIRD FIELD</th> </tr> <tr> <td>FIRST_OBJ_HERE_SHOULD_BE_THE_FIRST_FIELD</td> <td>FIRST_OBJ_HERE_SHOULD_BE_THE_SECOND_FIELD</td> <td>FIRST_OBJ_HERE_SHOULD_BE_THE_THIRD_FIELD</td> </tr> <tr> <td>SECOND_OBJ_HERE_SHOULD_BE_THE_FIRST_FIELD</td>

How to show a table from a slice with my struct

偶尔善良 提交于 2021-02-11 18:25:59
问题 I want to show a table that each row contains my struct data. Here is my struct: type My_Struct struct { FIRST_FIELD string SECOND_FIELD string THIED_FIELD string } Here is my html code: <table id="t01"> <tr> <th>FIRST FIELD</th> <th>SECOND FIELD</th> <th>THIRD FIELD</th> </tr> <tr> <td>FIRST_OBJ_HERE_SHOULD_BE_THE_FIRST_FIELD</td> <td>FIRST_OBJ_HERE_SHOULD_BE_THE_SECOND_FIELD</td> <td>FIRST_OBJ_HERE_SHOULD_BE_THE_THIRD_FIELD</td> </tr> <tr> <td>SECOND_OBJ_HERE_SHOULD_BE_THE_FIRST_FIELD</td>

Unit tests panic when returning dereferenced struct attribute rather than struct

偶尔善良 提交于 2021-02-11 18:24:40
问题 How does one go about testing a function that is returning a struct attribute that is of type string or number, rather than the struct itself? I am trying to test the Lambda Code block with the Test Code block. In Lambda Code block below, I am returning *resp.UserPoolClient.ClientSecret which dereferences to a string , rather than the *string . When I run my test, I believe I get a panic error as *resp.UserPoolClient.ClientSecret is nil in the debugger. Is my returning of the de-referenced

How to sign cert with an arbitrary or deprecated extension

此生再无相见时 提交于 2021-02-11 18:16:09
问题 For example say I want to sign a cert with an arbitrary or deprecated extension (nsCertType for example): https://www.openssl.org/docs/manmaster/man5/x509v3_config.html I believe I'm supposed to add the arbitrary extension as part of the certificate as per below but how / where do you discover the asn1 object identifier? I've read more documentation that I care to admit today and am still stumped. tmpl := &x509.Certificate{ SerialNumber: big.NewInt(time.Now().Unix()*1000), Subject: pkix.Name

How to sign cert with an arbitrary or deprecated extension

我怕爱的太早我们不能终老 提交于 2021-02-11 18:12:32
问题 For example say I want to sign a cert with an arbitrary or deprecated extension (nsCertType for example): https://www.openssl.org/docs/manmaster/man5/x509v3_config.html I believe I'm supposed to add the arbitrary extension as part of the certificate as per below but how / where do you discover the asn1 object identifier? I've read more documentation that I care to admit today and am still stumped. tmpl := &x509.Certificate{ SerialNumber: big.NewInt(time.Now().Unix()*1000), Subject: pkix.Name

How to sign cert with an arbitrary or deprecated extension

跟風遠走 提交于 2021-02-11 18:11:18
问题 For example say I want to sign a cert with an arbitrary or deprecated extension (nsCertType for example): https://www.openssl.org/docs/manmaster/man5/x509v3_config.html I believe I'm supposed to add the arbitrary extension as part of the certificate as per below but how / where do you discover the asn1 object identifier? I've read more documentation that I care to admit today and am still stumped. tmpl := &x509.Certificate{ SerialNumber: big.NewInt(time.Now().Unix()*1000), Subject: pkix.Name

Vue开发之vue-router的基本使用

回眸只為那壹抹淺笑 提交于 2021-02-11 17:25:06
来源 | http://www.fly63.com/article/detial/8806 一、安装 1、如果你用vue-cli脚手架来搭建项目,配置过程会选择是否用到路由,如果选择Yes,后面下载依赖会自动下载vue-router。 Install vue-router? Yes 2、npm npm install vue-router 二、将组件 (components) 映射到路由 (routes)并渲染 步骤一 使用vue-cli搭建项目,项目结构中会有一个src文件目录,src文件目录下会有一个router文件夹,此处就是用来编写路由组件的地方。 在src/router/index.js,这个文件就是路由的核心文件。在这个文件里,我们需要做的是,将组件 (components) 映射到路由 (routes)。 // 0. 如果使用模块化机制编程,导入Vue和VueRouter,要调用 Vue.use(VueRouter) import Vue from 'vue' // 导入vue import VueRouter from 'vue-router' // 导入vue-router Vue.use(VueRouter) // 1. 定义(路由)组件 import Home from '@/components/Home' // 2. 创建 router 实例,然后传