Auto open apps on Mac

I poweroff my laptop every night. So I have to open some app I use everyday when I started the laptop. I use a script by Justin Hileman, to open news tabs in terminal. Save this script as init.sh, run sh init.sh in the terminal, and it will do several things: run wg.sh, setup wireguard tunnal open new tab, start a tmux session open new tab, using mosh to ssh a server open new tab, open a txt file using vim open github in chrome start vs code show a popup message #!/bin/bash # # Open new Terminal tabs from the command line # # Author: Justin Hileman (http://justinhileman.com) # # Installation: # Add the following function to your `.bashrc` or `.bash_profile`, # or save it somewhere (e.g. `~/.tab.bash`) and source it in `.bashrc` # # Usage: # tab Opens the current directory in a new tab # tab [PATH] Open PATH in a new tab # tab [CMD] Open a new tab and execute CMD # tab [PATH] [CMD] ... You can prob'ly guess function tab () { local cmd="" local cdto="$PWD" local args="$@" if [ -d "$1" ]; then cdto=`cd "$1"; pwd` args="${@:2}" fi if [ -n "$args" ]; then cmd="; $args" fi osascript &>/dev/null <<EOF tell application "iTerm" tell current window set newTab to (create tab with default profile) tell newTab tell current session write text "cd \"$cdto\"$cmd" end tell end tell end tell end tell EOF } function alert(){ title="$1" msg="$2" osascript &>/dev/null <<EOF display notification "$msg" with title "$title" EOF } ~/wg.sh || exit tab "tmux new -s x" tab "mosh root@xxxx" tab "vi notes.txt" open -a "Google Chrome" https://github.com/ code alert "have a nice day"

December 21, 2023 · notsobad

Using Windows

最近开始用一台旧的XPS 13笔记本,之前被自动升级到了win 11,于是就开始了windows的体验,目前可以使用WSL2,里面安装了ubuntu 22.04, 然后发现了另外一个比较有意思的软件,就是winget, 这个之前一直没有用过,这次就体验了一下。 winget是一个windows的命令行的软件管理器,运行winget update, 它会自动探测系统中已安装的软件版本,然后和数据库中对比,之后就可以选择性的升级。命令行安装或者升级软件还是很方便的,除了部分软件会弹出一个权限确认的窗口外,基本不需要人工交互。这个解决了windows没有软件库的问题,也解决了升级问题。不是所有软件都自身带有自动升级和新版本检测的,比如kicad,不用winget的话,想更新就要自己去官网检查、下载、安装才可以。 ...

December 1, 2023 · notsobad

vscode Tips

不同步某些配置项 参考:https://code.visualstudio.com/docs/editor/settings-sync#_configuring-synced-data 可以设置settingsSync.ignoredSettings, 或者直接在gui上,将“同步此配置”的勾选去掉。比如我可能希望在不同的设备上有不同的主题,就可以配置为 ...

November 20, 2023 · notsobad

Gitlab Ci Tips

调试ci 参考这篇文章: https://www.lullabot.com/articles/debugging-jobs-gitlab-ci 本地配置gitlab runner环境 在本地代码中操作,修改ci脚本使其在适当的位置sleep 本地提交改动过的代码,注意ci只会执行在git仓库中的代码 运行runner docker exec进入运行中的容器 本地运行runner,注意增加超时时间,避免被杀掉 ...

October 8, 2023 · notsobad

Clickhouse Tips

投影projection 官方文档https://clickhouse.com/docs/en/sql-reference/statements/alter/projection 创建这个特性时的讨论:https://github.com/ClickHouse/ClickHouse/issues/14730 ...

September 14, 2023 · notsobad

ffmpeg Tips

安装 brew install ffmpeg --with-libvpx --with-libvorbis --with-ffplay ffmpeg -codecs ffmpeg -f avfoundation -list_devices true -i "" 查看文件信息 ffmpeg -i screen.mp4 录屏 ffmpeg -r 30 -f avfoundation -i 1 -vcodec vp8 -quality realtime screen2.webm ffmpeg -r 30 -f avfoundation -i 1 -vcodec h264 screen.mp4 视频转换为gif ffmpeg -ss 2 -t 4 -i screen.mp4 -s 240x180 screen.gif 视频转为图片 ffmpeg -i video.mp4 image%d.jpg 视频文件的前十秒,每一秒生成一张图片 ffmpeg -i Downloads/硅谷第5季第一集.mp4 -r 1 -frames 10 -f image2 xx-%3d.jpeg 直播 docker run -it --rm -p 9080:80 -p 1935:1935 -v ~/tmp:/usr/local/nginx/html chakkritte/docker-nginx-rtmp ffmpeg -y -loglevel warning -f avfoundation -i 1 -r 30 -s 480x320 -threads 2 -vcodec libx264 -f flv rtmp://test-serv:1935/live/test ffmpeg -y -loglevel warning -f avfoundation -i 0 -s 480x320 -threads 2 -vcodec libx264 -f flv rtmp://test-serv:1935/live/test ffmpeg -f avfoundation -framerate 30 -i "2:0" -f avfoundation -framerate 30 -video_size 640x480 -i "0" -c:v libx264 -preset ultrafast -filter_complex 'overlay=main_w-overlay_w-10:main_h-overlay_h-10' -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://test-serv:1935/live/test 摄像头录制 ffmpeg -f avfoundation -framerate 30 -i "0" -target pal-vcd ./test.mpg 提取文件长度 ffprobe -i $i -show_entries format=duration -v quiet -of csv="p=0" ffmpeg -i ~/新录音\ 9.m4a random.wav 拆分文件 ffmpeg -i random.wav -f segment -segment_time 9 -c copy random-%03d.wav 局域网内多播 https://news.ycombinator.com/item?id=34912300 ...

August 31, 2023 · notsobad

Archlinux Tips

使用archinstall进行安装,注意终端只有一个tty,错误输出会打印到这个tty里,可以临时禁用错误输出。 dmesg -n 1 另外archinstall中输入密码时如果发现无法回车确认,可以用ctrl + j来代替回车。 安装gnome pacman -S gnome systemctl enable gdm systemctl start gdm 安装KDE ...

August 29, 2023 · notsobad

Golang Tips

快速的单个文件测试 # run without build go run main.go # 如果 main.go依赖test.go, 那就需要指定好依赖文件,或者用go build go run main.go test.go # or build it go build -o xxx main.go ./xxx godoc 文档: go install golang.org/x/tools/cmd/godoc@latest godoc -http :6060 # visit http://localhost:6060/ 使用protobuf,需要安装protoc-gen-go, 同时~/go/bin要在 PATH 里 ...

August 21, 2023 · notsobad

休假记录

最近休了个年假,一家三口去开车出去玩,没有计划,只是看着地图,按照一天能开的路程选目的地,最终去了贵州、广西、云南。 首站在贵州遵义,去看了个溶洞和地下裂缝景区,还是不错的,比较凉快,但是小孩太小,几乎全程抱着,很累。 然后就前往广西,在桂林去坐了竹筏和看了象鼻山,桂林太热了,热门景区人非常多,为了坐竹筏在太阳下排了 2 个小时的队,而且是带着小孩。之后就很快决定到云南去,中间在百色住了一晚,去了百色一个山上的一个湿地公园,一般。 ...

August 12, 2023 · notsobad

Zelda TOTK

5月份底时候拿到了《王国之泪》,玩到现在,昨天看刚好100个小时,进度是拿到了3个贤者,地下只去了很少一部分,天空也没怎么探索。 对比下之前玩《旷野之息》的情况,这次因为熟悉故事背景和流程,所以前期很快的就把塔全部打开,找到了塔视野范围内的神庙,在前期只有几颗心的情况下,稀里糊涂的就把“风”的任务打过了,但后来“水”、“雷”的boss卡了很久,会被一击致命,死了很多次之后,就放着了,继续去玩支线、找神庙。

July 21, 2023 · notsobad