Tailscale
丁宇在推特上说这个东东比 frp 好用。我先一口气把它安装到四台服务器性质的 Linux 机器上,包括两台本来就有外网 IP 的vps,然后才琢磨这东西有啥用,怎么用。安装和授权过程都很简洁,没有废话,第一印象棒极了。
那...它有啥用呢?一句话,它把你所有的机器,不论物理上隔多远,放到一个局域网里了。在这个局域网里,没有防火墙,网内可以访问任何设备的任何端口。和普通的vpn不同,它没有中央设备,所有设备之间都是直连,因此性能比较好。
那有啥用呢?
- 管理你的一堆机器更方便了。
- 局域网内任何一台有外网IP的机器都能做为任何一台内网机器的跳板机(内网无端口限制的穿透)。
换言之,你的VPS只要有足够的流量,硬盘空间不再是限制你部署应用的瓶颈,你完全可以把你的各种试验性side project部署在你的家里,或者父母的家里,扔台旧机器装个Linux就全齐活了。
嗯,它不光支持 Linux,还支持macOS,iOS,Windows!牛大了。
记录一下小坑。macOS 10.15.4 安装好后 Login 是灰的,无法登录,重启下电脑就好了。
这是我从新近follow的一个推友 @tywtywtyw 的推文里拣到的宝。他在推文里说
放弃了 postman 和 postwomen, 来到了 insomnia
能比 Postman 更好?这勾起了我的好奇心。结果发现真香。
顺便说一下,他的口号是“Design and debug APIs like a human, not a robot.”
- 不用写脚本,可以指定当前请求依赖哪个请求,以及是使用缓存的请求结果,还是需要时再发新请求(通常我都会选择发新请求,毕竟token会过期)
- 最重要的键是 Ctrl+空格。这是 autocomplete 的热键。
- 界面相对易用。
- 有父环境和子环境的概念,公共的东西写到父环境里,能省一些时间
- 就像使用苹果的软件,你不需要专门保存你的接口,你写了,你run了,接口就自动存好了。
遇到一个坑:如果是在JSON里使用环境变量,并且这个变量是个字符串,得用双引号括住这个变量!
我已经决定扔掉 Postman 了。就是这么喜新厌旧。
It spent more than half an hour. Finally, I found this solution.... very simple!
#!/bin/bash
/usr/local/bin/noip2 -c /usr/local/etc/no-ip2.conf
sleep 1
noip sucks!
source
Two bash script achieved the goals in this subject.
1. Exporting data dictionary
cat utils/exportDbDictionary
if [ $# != 2 ] ; then
echo "USAGE: $0 dbname tablename"
echo " e.g.: $0 IDServer AspNetUsers"
exit 1;
fi
document_path=/YourProjectName/documents/database
[ -d $document_path/$1 ] || mkdir -p $document_path/$1
mysqlshow $1 $2 | sed 's/+/|/g' | sed '1,2d' | sed '$d' | awk -F"[|]" '{print $2"|"$3"|"$5"|"$6"|"$7"|"$10}' | sed 's/ *$//g' > $document_path/$1/$2.md
People should always add comments to their field definitions. As soon as the definition of a table has been done, run this script could automatically generate a markdown table with the name of tableName.md.
2. export database structure without auto_incrment= statements
cat utils/backupDbStructure
backupFile=/YourProjectName/documents/database/databaseStructure.sql
mysqldump -d --databases YourDB1 YourDB2 YourDB3 | sed 's/ AUTO_INCREMENT=[0-9]*//g' > $backupFile
When you made some changes to your database, run backupDbStruture script will automatically generate the latest table structure into one file. You could commit it later with your code change together.
If the field names in your Model class are not exactly the same as in a JSON string, you will need adding an option to guarantee the behavior is what you want. For example, if you have got the following response text:
{"hello":"world"}
and you have a Model class below:
class SampleModel
{
public string Hello { get; set; };
}
You can see the property name in your Model class is "Hello" instead of "hello", the following code won't get an expecting result.
SampleModel s = JsonSerializer.Deserialize<SampleModel>("{\"hello\":\"world\"}");
you will get an object like
{
"Hello": null
}
You have to use an option below to get it to work.
SampleModel s = JsonSerializer.Deserialize<SampleModel>("{\"hello\":\"world\"}", new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
});
on the other hand, you have to use the following code to guarantee the serialize behavior:
SampleModel s = JsonSerializer.Serialize(new SampleModel() {Hello="world"}, new JsonSerializerOptions
{
DictionaryKeyPolicy = JsonNamingPolicy.CamelCase
});
Thus you get {"Hello":"world"} instead of {"hello":"world"}.
System.text.json sucks.