Skip to content

Instantly share code, notes, and snippets.

View leafney's full-sized avatar

Leafney leafney

View GitHub Profile
@leafney
leafney / cloud_music.json
Created February 8, 2023 01:56
Cloud music player implemented by Node-Red and HomeAssistant
[{"id":"0d1d65f7ba1553ca","type":"tab","label":"云音乐播放器","disabled":false,"info":"","env":[]},{"id":"33759b693780be63","type":"inject","z":"0d1d65f7ba1553ca","name":"手动启动/停止","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":250,"y":240,"wires":[["dbc207429b6f6dc0"]]},{"id":"e9211b0583476c26","type":"function","z":"0d1d65f7ba1553ca","name":"设置音乐类别","func":"// 发起请求\nmsg.headers = {\n \"Content-Type\": \"application/json\"\n};\n\n// 随机类别 热歌榜|新歌榜|飙升榜|抖音榜|电音榜\nvar arr = ['热歌榜','热歌榜','新歌榜','飙升榜','抖音榜']\n\n// 随机获取一项\nvar random_type = arr[Math.floor(Math.random() * arr.length)];\n\nmsg.payload = {\n // \"sort\":\"热歌榜\",\n // 'mid':1, // 歌单ID\n \"sort\":random_type,\n \"format\":\"json\"\n}\n\n// 显示类别\nnode.status({fill:\"blue\",shape:\"dot\",text:random_type});\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":340,"wires":[["722779911f306151"]]},{"id":"722779911f306151","type":"http request","z":"0d1d65f7ba1553ca","name":"请求音乐信息"
void main() {
String? ss;
print(ss);
// ss = " ";
// ss="hello";
print(ss);
print('isNullOrEmpty: ${ss.isNullOrEmpty()}');
@leafney
leafney / show_k8s_ca_and_token_from_service_account.sh
Last active October 13, 2019 18:32
Get k8s/k3s token and ca.crt from ServiceAccount
#!/bin/bash
set -e
set -o pipefail
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
echo "usage: $0 <service_account_name> <namespace>"
exit 1
fi
@leafney
leafney / staticproxy.go
Last active May 6, 2024 07:53
golang下实现http代理请求
package main
/*
http代理测试
* [Mocking a HTTP access with http.Transport in Golang - oinume journal](http://oinume.hatenablog.com/entry/mocking-http-access-in-golang)
* [Go http访问使用代理](http://www.cnblogs.com/damir/archive/2012/05/06/2486663.html)
* [GO HTTP client客户端使用 - 海运的博客](https://www.haiyun.me/archives/1051.html)
* [Making Tor HTTP Requests with Go | DevDungeon](http://www.devdungeon.com/content/making-tor-http-requests-go)
@leafney
leafney / footer.tmpl
Created March 27, 2017 08:59
Docker Gogs custom files