nZh10's Website
Time 2022-09-21 22:10:59Web Name: nZh10's Website
WebSite: http://www.nzh10.com
ID:324125
Keywords:
WebsiteDescription:
Happy coding!
git's Memo
作者: nZh10 时间: 分类: 备忘 评论 When extracting files fromgit stash
(you can see here for more details) in Powershell, you may encounter a strange error which says error: unknown switch `e'
. It is caused by the
{}
character in Powershell: these braces are parsed unexpectedly. Use ` symbol to escape them: git checkout stash@
{0} -- /path/to/your/file
Rollback to any commit that you have ever committed:
git refloggit reset HEAD@{index}
Update your commit RIGHT after it has been committed:
git add .git commit --amend --no-edit # the commit will now contains what you have added
Change the message of my last commit: git commit --amend
move a just-committed one to a new branch
If you committed to master/main
:
# create a new branch from the current state of mastergit branch some-new-branch-name# remove the last commit from the master branchgit reset HEAD~ --hardgit checkout some-new-branch-name
If you committed to another branch:
git checkout name-of-the-correct-branch# grab the last commit to mastergit cherry-pick master# delete it from mastergit checkout mastergit reset HEAD~ --hard
Reference
My Programming Experiencehttps://dangitgit.com/enPowershell相关
作者: nZh10 时间: 分类: 备忘 评论Cheatsheets
设置代理
PS C:\> $Env:HTTP_PROXY="http://localhost:7890"PS C:\> $Env:HTTPS_PROXY="http://localhost:7890"
grep
equivalent - Select-String
Simple MatchingSelect-String -Path "Users\*.csv" -Pattern "Joe"
Multi-Pattern MatchingSelect-String -Path "Users\*.csv" -Pattern "Joe","Marti","Jerry"
RegEx with head
equivalentSelect-String -Path "Users\*.csv" -Pattern '\\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b' | Select-Object -First 10
Recursively search csharp src filesGet-ChildItem -Recurse *.cs | Select-String -Pattern 'keyword'
rm
equivalent - Remove-Item
可以直接用,但是需要注意,rm -rf
等价于 Remove-Item -Recurse -Force
,shell的参数不能直接用。
wget
and curl
equivalent - Invoke-WebRequest
下载文件这么写:Invoke-WebRequest -v https://path/to/file.exe -OutFile ./file.exe
如果想按照原来的名字呢?不幸地,你需要自己实现一个函数。当然你可以把函数像用bash一样保存在一个profile文件里,这个profile的路径可以用notepad $profile
直接打开:
Function My-Download { param ( [parameter(position=0)]$uri ) Invoke-WebRequest -uri $uri -OutFile $(Split-Path -path "$uri" -leaf)}
Troubleshooting
标记“&&”不是此版本中的有效语句分隔符。
对Windows自带的5.1版PS,不支持&&
操作符,需要这么用:
(command_1) -and (command_2)
如果不需要短路特性可以简单的使用分号隔开。
新版(Powershell 7以上)可以使用&&
。
一句话问题
命令补全感觉怪怪的:需要让它学bash,但是只有新版可以。在profile(上文提到过路径)里这么添加:
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
帮助文件下不下来:先考虑代理,如果在Windows中设置netsh winhttp set proxy "127.0.0.1:7890"
,在Linux/Mac中设置http{,s}_proxy
(要在运行前通过env设置,不要进入powershell内设置);再运行Update-Help -UICulture en-US
。 在IIS上配置Typecho的静态重写功能
作者: nZh10 时间: 分类: 建站 评论Typecho的静态重写的意思的实质就是将链接里的index.php去掉,这非常有用,因为方便迁移,但是网上你能搜到的教程全部都是Nginx了,这对于IIS而言就非常折磨了。
虽然也有IIS开启这个功能的相关文章,不过笔者还是再重新整理一下相应内容主要是自己实现的时候没搜到。这个功能本质不算复杂,只不过是文档太过晦涩了,具体的方法请参考如下的文章:
基本上这四个网站看完就能自己写了。但是会遇到一个拦路虎:怎么在线调试Azure Web App的网站呢?日志哪里看呢?虽然Azure有官方文档,但是说实话讲的跟面条一样,啥都讲了没有重点。笔者这里具体说下怎么看Rewrite的问题日志:
Failed request tracing是我们的重点,因此要先去Azure Portal->App Service Logging里打开Failed request tracing选项(Detailed error messages视情况也可打开);在浏览器里复现你的问题,可以多复现几次;然后打开你的网站的kudu后台(也就是Kudu Services),点击上方的Tools->Diagnostic dump,下载日志文件,里面就能看到具体的报错信息了。好的好的,知道你想要具体的规则怎么实现的,除了上面的地址以外,笔者的GitHub上也提供了相应的web.config文件。
添加插件与首页边栏元素(Typecho)
作者: nZh10 时间: 分类: 建站 评论添加了两个插件,一个是友情链接,另一个是reCaptcha。二者的git仓库地址见下:
https://github.com/Zisbusy/Akina-for-Typecho 里带的Links插件(修复了一些安全的bug,原版还是2013年的)https://github.com/KawaiiZapic/Typecho-reCAPTCHA-v3 注意,一定根据Readme里的要求改名字插件的添加不再赘述,这里重点聊聊一些网上没讲过的问题:
部署问题。如果在Azure里使用的是Local git部署,那么直接git push
上去就行,Kudu会自动diff差别,将插件同步到系统中。添加具体的插件逻辑代码。recaptcha很好添加,重点是友链,需要修改主题的相关文件。
在themes/sidebar.php
中添加这段代码:
<?php if (!empty($this->options->sidebarBlock) && in_array('ShowLinks', $this->options->sidebarBlock)): ?> <section class="widget"> <h3 class="widget-title"><?php _e('链接'); ?></h3> <ul class="widget-list"> <?php Links_Plugin::output(); ?> </ul> </section> <?php endif; ?>
很显然,里面出现了ShowLinks
这样的选项。因此还要再去主题的functions.php
里更改,也就是添加一个ShowLinks
的option,这方面的资料参考这里。
主题方面的更新之后再说吧,感觉一次改动太多很折磨- -毕竟自己不是写php的
配置域名与SSL
作者: nZh10 时间: 分类: 建站 1 条评论之前使用的是Azure自带的域名,这里终于可以使用上自己带的域名了。网上找了个Godaddy的优惠码,前两年年均只需要60大洋就能拿下,还是很实惠的。但是需要注意的一点,如果发现付款时提示“处理您的交易过程中出现问题。请验证您的付款信息,或使用另一种付款形式。”这个报错,请切回首页,拉到最底部的结算方式,将CNY改为USD,然后切回来使用Paypal支付。这个在现在(2022年4月)是可行的。
拿下域名后就可以在Godaddy和Azure的后台配置相应信息了,这里必须夸一下Azure的文档,写得很齐全,里面也介绍了在Godaddy里如何添加记录。一般只需要添加根域的记录即可,CNAME的记录不需要添加,因为你可以通过Godday配置301跳转跳到根域名(当然如果你有其他科学上网的需求另当别论)。
最后就是配置SSL,Azure中可以直接添加DigiCert的证书,基本上只要点点就可以完成,还是很方便的。从这里可以看到具体的流程。
这么一来,该有的设置基本都有了。虽然考虑做个CDN,但是看了网上的一些其他博客似乎也没搞这个,先鸽了,之后再说吧
TAGS:Website
<<< Thank you for your visit >>>
Websites to related : Fundació Privada Sant Pau | Web
Vés al contingut caes La FundacióSuport a l'assistènciaImpuls de la recercaRecursos per a la docèn
Kent, OH | Official WebsiteSkip to Main Content Loading Close
Kansas State University - AhearnSkip To Main Content
UNC Greensboro - Official AthletSkip To Main Content
Fordham University Athletics - OSkip To Main Content
University of Pittsburgh Band -Skip To Main Content
Elon University Athletics - OffiSkip To Main Content
Volusion: Ecommerce Website Buil FeaturesPricingThemesResourcesHelp Center Reference expertly-written
support articles and tutorialsBlog Fresh ecommerce insightsEducational Resources
ChinaContact usMake power more reliable*ProductsServicesMarketsSupportCompanySearchToggle Mobile MenuProductsClose Search Product OverviewSTSATSPDUUPS
Privacy-friendly Website Analytihtml{--c:#333;--c-light:#bbb;--c-nav:#fff;--c-badnews:#f77;--c-goodnews:#5c5;--c-message:#666;--c-link:#2e7bc9;--c-link-hover:#000;--c-link-domain:#00
adsHot Websites