Powershell的配置

Powershell配置文件 ###第一步,安装Powershell 在microsoft store 里面安装Powershell,不要用microsoft powershell,后者是电脑自带的。 第二步,安装一个终端的编辑器 比如nano,vim,这两个在Linux上用的比较多,但是Windows上比较复杂,而且有学习成本,这里推荐一个 GitHub开源的编辑器,micro,他的快捷键都是Windows的标准,没有入门的门槛。项目地址:GitHub micro 链接 打开powershell,输入micro -mkparents true $profile 随便输入一个东西,比如#xxx然后ctrl+s保存。 本人用的配置文件分享 Set-Alias getlist ls Set-Alias cl 'clear' Set-Alias py python #打开历史记录 Set-PSReadLineOption -PredictionSource History #Set-Alias ppip "pip -i http://pypi.doubanio.com/simple/ --trusted-host pyi.doubanio.com" #Set-Alias pr './pr.ps1' $mypath="C:/users/ian/ianhome/mypath" function nnmap([string]$parm){ echo $parm nmap $parm -O -sS } function pr(){ set t "powershell全局代理" echo $t $Env:http_proxy="http://127.0.0.1:11223" $Env:https_proxy="http://127.0.0.1:11223" $t="代理地址:" echo $t echo $Env:http_proxy echo $Env:https_proxy } function nopr(){ echo "终端取消代理..." $Env:http_proxy="" $Env:https_proxy="" } function ppip([string]$mod,[string]$r){ echo $parm echo "pip 临时换源安装ing" $command="" if($r){ echo "read TXT mode" $command="pip install -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com -r "+$r pip install -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com -r $r } elseif($mod){ echo "Common Mode" $command="pip install -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com "+$mod pip install -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com $mod } else{ echo "Error No input module" echo "Use : ppip xxx OR ppip -r requirements.txt" } echo "Used Command: " echo $command return }

September 20, 2022 · 1 min · 147 words · IanTang

浅谈go二维数组的深复制

浅谈go二维数组的深复制 在go语言中,对于一个数组的赋值,和python一样,其实并没有开辟新空间,比如下面这行代码: package main import "fmt" func main(){ source:=[]int{1,2,3,4} dist:=[]int{} dist=source dist[0]=999 //对第二个数组进行修改 fmt.Println(source) } 打印的结果,为 [999,2,3,4]。这时候如果想对第二个数组进行修改,并且不影响原数组,也就是说,想让他们两个独立,这时候就需要关键字copy package main import "fmt" func main(){ source:=[]int{1,2,3,4} dist:=[]int{} copy(dist,source) dist[0]=999 //对第二个数组进行修改 fmt.Println(source) } 输出的结果为[1,2,3,4]。这是一维数组,很好写,也很简单。 二维数组的情况 二维数组的时候,情况变得复杂起来,比如你看下面的代码 package main import "fmt" func main(){ source:=[][]int{{1,2,3,4},{5,6,7,8}} dist:=[][]int{} copy(dist,source) fmt.Println(dist)//直接对第二个数组进行输出 } 输出的结果:[] 为空,虽然没有报错,但是实际并没有成功,也就是说,copy只能复制一维的,那我们可以遍历二维数组,然后一个一个的进行复制,行不行?答案是:可以,但是对于写法有要求。先来一份正确的写法 package main import "fmt" func main(){ source:=[][]int{{1,2,3,4},{5,6,7,8}} dist:=make([][]int,len(source)) for i:= range source{ dist[i]=make([]int,len(source[i])) copy(dist[i],source[i]) } fmt.Println(dist) } 上面的代码中,有两个make,都不可以省略。第一个make开辟数组的行数,(注:len(source)的值为2,因为source只有两行。)。第二个make开辟数组的空间,这个比较好理解。下面是错误的示范。 ...

July 10, 2022 · 1 min · 123 words · IanTang

各个终端设置代理的方法

端口以11223为例子 cmd: set http_proxy=http://127.0.0.1:11223 & set https_proxy=http://127.0.0.1:11223 powershell: $Env:http_proxy="http://127.0.0.1:11223";$Env:https_proxy="http://127.0.0.1:11223" unix: export HTTP_PROXY=http://127.0.0.1:11223; export HTTPS_PROXY=http://127.0.0.1:11223; export ALL_PROXY=socks5://127.0.0.1:11223 pip: -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com #临时换源 npm config set registry https://registry.npm.taobao.org #npm 永久镜像 npm install -g cnpm --registry=https://registry.npm.taobao.org #用cnpm代替,cnpm走国内,npm不做任何更改 to do……

July 8, 2022 · 1 min · 37 words · IanTang

Python+QT打包为单个exe的方法

Python打包exe Python打包exe用pyinstaller,很简单,网上有很多教程, 对于python程序打包,使用的都是pyinstaller,以下为pyinstaller的一些用法。 -F 只生成EXE -icon 指定exe的icon -w 去除黑框框 在生成完exe后,里面不会包含QT的ui文件,不仅是ui,images及各种媒体文件都不会包含,需要自己在源代码中指定路径(这里建议使用相对路径)。当我们想把这个程序分享给别人的时候,需要分享一个压缩包,这一点都不优雅,因为通常来说python+QT我们普通人写的都是一些小项目,因此如果能打包成一个exe,绿色运行就好了,这里介绍一个软件,enigma virtual box,它可以把程序打包为单个exe文件,绿色运行,看软件的名字就可知道,打包之后的exe相当于一个虚拟机,里面包含了所有文件。 软件官网:EnigamaVirtualBox官网

July 8, 2022 · 1 min · 13 words · IanTang

test

test yes,this is a test page

July 7, 2022 · 1 min · 6 words · IanTang