跳至主要内容

博文

PowerShell Exercises - Rename file names in batch

以前用TotalCommander来做batch rename的,GUI下输入pattern挺方便的。现在的PC上没有安装,于是要靠命令行了。 好在PowerShell的pipe也不算太糟糕: Get-ChildItem directory | Rename-Item -NewName { $_.Name -replace '^filename_+','' } 如果有多个 patterns 需要替换可以使用多组 `-replace` 表达式组合。

组合使用 you-get 和 ffmpeg

最近对 `you-get` 这个神奇的下载器挺感兴趣的,用它在油管上下了一些MV,顺手下了另一个大名鼎鼎的工具 `ffmpeg` 将歌曲转换为 MP3。 > you-get -o D:\DOWNLOAD http://some-url 假定文件保存为 `'some-mv.mp4'`, > ffmpeg -i D:\DOWNLOAD\some-mv.mp4 -vn -ab 256k some.MP3。 有的时候如果需要截取部分来转换,可以加上两个参数 `-ss` 和 `-to`: > ffmpeg -i D:\DOWNLOAD\some-mv.mp4 -vn -ab 256k -ss 00:03:12 -to 04:15:43 sub-convert.mp3 简单的参数解释: + `-vn` 不要视频,也就是转换为音频格式 + `-ab bitrate` 指定音频的比特率 + `-ss time_offset` 指定从哪个时间点开始 + `-to time_stop` 指定停止的时间点 当然 `ffmpeg` 提供的参数远不止这些,[这里](http://blog.topspeedsnail.com/archives/1699)有一片不错的使用介绍可以参考。

From markdown to PDF using Pandoc

花了点儿时间玩 Pandoc,将一些 Markdown 文档转换为 PDF 文档。 首先参考[官方文档](https://pandoc.org/installing.html)在 Mac OS 上安装了 Pandoc: > You can install pandoc using homebrew: `brew install pandoc`. > > There is a package installer at pandoc’s download page. If you later want to uninstall the package, you can do so by downloading this script and running it with perl uninstall-pandoc.pl. > > We also provide a zip file containing the binaries and man pages, for those who prefer not to use the installer. Simply unzip the file and move the binaries and man pages to whatever directory you like. > > For PDF output, you’ll also need LaTeX. Because a full MacTeX installation takes more than a gigabyte of disk space, we recommend installing BasicTeX (64M) and using the tlmgr tool to install additional packages as needed. If you get errors warning of fonts not found, try `tlmgr install collection-fontsrecommended` 安装了 BasicTex 之后一直在 Apps 里寻找 `LaTex` 或是 `BasicTex` 这样的应用,但是一无所获(?!) 后来跑到 MacTex...

Code to Graph

花了点儿时间寻找适合 code 转换为 graph 的工具,发现了 pandoc 和 Graphviz。 [Graphviz](https://graphviz.gitlab.io/documentation/) 貌似比较有趣,下载了一个Windows的版本,安装之后在 Win10 上没有任何的图标添加,要自己到安装目录下找到 `bin/gvedit.exe` 打开。 另外找到了一篇[很详细的攻略](http://blog.jobbole.com/94472/)来学习如何使用 Dot 语言来绘图。

解决由ATI显卡驱动导致的爆音

一直以来电脑有个问题,在开始播放音乐或是看片的时候,音箱里首先一下爆音。如果播放的音频时间很短,那么干脆就听不见——甚至连Windows的开机声音也没有。 花了点儿功夫求助Google,初步得到的结论是由于PC上的ATI显卡驱动和主板的Realtek音频驱动有冲突导致的。后来找到了 [Realtek 官网所提供的 High Definition Audio Codecs](http://www.realtek.com.tw/downloads/downloadsCheck.aspx?langid=1&pfid=24&level=4&conn=3&downtypeid=3),其中有一个专门为 ATI 设备编写的驱动名为『ATI HDMI Audio Device』,版本是R2.70,虽然最后的更新时间是五年前(2012/6/2)不过这不重要,果断下载安装。 重启后一切搞定~

Running Kubernutes in Windows 10

试着在 Windows 10 PC 上玩 docker 和 Kubernetes。作为容器管理平台,Kubernetes 可以被安装并运行在不同类型的环境下,包括开发者的笔记本电脑,或是云服务商的VM,甚至是一组裸机上…… 参考官方文档 [Picking the Right Solution](https://kubernetes.io/docs/setup/pick-right-solution/) 找到了适合创建单机单节点 Kubernetes Cluster 的 [Minikube](https://kubernetes.io/docs/getting-started-guides/minikube/#minikube-features)。 Minikube 提供的特性包括: * DNS * NodePorts * ConfigMaps and Secrets * Dashboards * Container Runtime: Docker, rkt and CRI-O * and etc. 安装 Minucube 的步骤看起来也挺简单的,先要 PC 的 BIOS 支持 VT-x 或是 AMD-v 虚拟技术,这年头只要不是太老的 PC 都行。接着需要在 OS 里装一个 Hypervisor,对 Windows 而言常见的就是 VirtualBox 或者 Hyper-V。 之前为了安装 Docker for Windows 卸载了 VirtualBox 改用 Hyper-V,因为 docker 的文档 [Machine Driver](https://docs.docker.com/machine/drivers/hyper-v/) 里明说了: > Hyper-V must be enabled on your desktop system. Docker for Windows automatically enables it upon install 谁让人家是微软的亲儿子捏? 接着要安装 `kubectl` 这是 Kubernetes 的 CLI (命令行工具),在 Windows 10 里可以利用 Chocolatey 包管理器来[代为安装](https://kubernetes.io/docs/tasks/tools/inst...

Docker in Windows 10

在 Windows 10 里头玩 docker,先安装 docker for windows 套件,然后直接可以用 PowerShell Console 来执行 `docker ps` 等指令。十分流畅地开始玩耍。 不过在尝试另一个 console - Windows 10 整合了 Ubuntu 的 bash,可以直接 Win+R 来执行 `bash` 打开命令行窗口。在里面就无法使用 docker,哪怕是 `sudo apt-get install docker` 也不成。 后来参考一个大牛的帖子 —— [Windows 10 bash & Windows docker 問題處理](https://blog.caesarchi.com/2017/05/15/windows-10-bash-windows-docker-intergrate_problem_solve/) 解决了。 摘录指令如下: ``` $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get update $ sudo apt-get install docker-ce ``` 总结一下:Win 10 总体来说比以前的 Windows (对Linux)友好了很多,但是小坑不少~