我使用以下命令将 rancher 安装到本教程中的现有 kubernetes 集群中:
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
kubectl create namespace rancher
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.0.4/cert-manager.crds.yaml
helm repo add jetstack https://charts.jetstack.io
helm repo update
kubectl get pods --namespace cert-manager
helm install rancher rancher-latest/rancher \
--namespace rancher \
--set hostname=rancher.blabla.com
kubectl -n rancher rollout status deploy/rancher # wait
kubectl -n rancher get deploy rancher
Run Code Online (Sandbox Code Playgroud)
此页面的卸载方法
./system-tools_linux-amd64 remove -c ~/.kube/config -n rancher
Run Code Online (Sandbox Code Playgroud)
但它显示一个错误:
Are you sure you want to remove Rancher Management Plane in Namespace [rancher] [y/n]: …Run Code Online (Sandbox Code Playgroud) 我知道如何创建一组值的排列.例如:
[*1..3].permutation(2)
Run Code Online (Sandbox Code Playgroud)
这导致以下六种排列:
[1, 2]
[1, 3]
[2, 1]
[2, 3]
[3, 1]
[3, 2]
Run Code Online (Sandbox Code Playgroud)
但是这个结果缺少三个排列,它们是相同值的组合,即:
[1, 1]
[2, 2]
[3, 3]
Run Code Online (Sandbox Code Playgroud)
如何获得所有排列,包括上面的重复排列?
有没有办法让Ruby能够做到这样的事情?
class Plane
@moved = 0
@x = 0
def x+=(v) # this is error
@x += v
@moved += 1
end
def to_s
"moved #{@moved} times, current x is #{@x}"
end
end
plane = Plane.new
plane.x += 5
plane.x += 10
puts plane.to_s # moved 2 times, current x is 15
Run Code Online (Sandbox Code Playgroud) 我有一个去计划 test.go
package main
import "fmt"
var DEBUG_MODE bool = true
func main() {
fmt.Println(DEBUG_MODE)
}
Run Code Online (Sandbox Code Playgroud)
我想DEBUG_MODE在编译时将变量设置为false
我试过了:
go build -ldflags "-X main.DEBUG_MODE 0" test.go && ./test
true
kyz@s497:18:49:32:/tmp$ go build -ldflags "-X main.DEBUG_MODE false" test.go && ./test
true
kyz@s497:18:49:41:/tmp$ go build -ldflags "-X main.DEBUG_MODE 0x000000000000" test.go && ./test
true
Run Code Online (Sandbox Code Playgroud)
它不起作用,但是当它DEBUG_MODE是一个时它起作用string
我有一张这样的桌子;
CREATE TABLE test (
id BIGSERIAL PRIMARY KEY,
data JSONB
);
INSERT INTO test(data) VALUES('[1,2,"a",4,"8",6]'); -- id = 1
INSERT INTO test(data) VALUES('[1,2,"b",4,"7",6]'); -- id = 2
Run Code Online (Sandbox Code Playgroud)
如何更新元素data->1,并data->3为其他的东西没有PL/*?
转换[]int8为字符串的最佳方式(最快的性能)是什么?
对于[]byte我们可以做string(byteslice),但[]int8它给出了一个错误:
cannot convert ba (type []int8) to type string
Run Code Online (Sandbox Code Playgroud)
我得到了ba来自SliceScan()的方法*sqlx.Rows产生[]int8的,而不是string
这个解决方案最快吗?
func B2S(bs []int8) string {
ba := []byte{}
for _, b := range bs {
ba = append(ba, byte(b))
}
return string(ba)
}
Run Code Online (Sandbox Code Playgroud)
编辑我的坏,它uint8不是int8..所以我可以string(ba)直接做.
什么是等价的std::vector,std::deque并std::map在ObjectPascal(FreePascal的编译器)?
简单来说:
(向量)是一个自动调整大小的连续数组
(deque)是阵列的自动调整大小的混合阵列,可提供接近O(1)的随机访问,同时允许从任一端进行O(1)推入/弹出
(map,unordered_map)是一个关联数组
我有这种代码,目的是包装,UnityEngine.Debug.Log这样我就可以在生产中禁用它们,以便我可以稍后查找/过滤。
using System;
public enum LogType
{
DEBUG,
CRITICAL
}
public class LogHelper
{
public static void Log(LogType lt, string format, params object[] objs)
{
if (lt == LogType.CRITICAL)
{
// StackTrace st = new StackTrace(new StackFrame(true));
// Console.WriteLine(" Stack trace for current level: {0}", st.ToString());
// StackFrame sf = st.GetFrame(0);
// Console.WriteLine(" File: {0}", sf.GetFileName());
// Console.WriteLine(" Method: {0}", sf.GetMethod().Name);
// Console.WriteLine(" Line Number: {0}", sf.GetFileLineNumber());
// Console.WriteLine(" Column Number: {0}", sf.GetFileColumnNumber());
}
// TODO: write to …Run Code Online (Sandbox Code Playgroud) 我知道如何使用package_info获取版本,但是如何在iOS和android上的Runtime中获取构建时间戳?
如何在Map没有forEach(所以我可以break在中间的情况下迭代javascript,或者有没有办法break从forEach?无法使用对象,因为顺序有时在某些浏览器上是随机的,其中Map顺序是按照定义的。
let map = new Map();
map.set(1,'google.com');
// very long list
map.set(12312,/[^a-z]+/);
let match = 'nothing';
for(let z in map) { // doesn't work, but works for object
if( foo.match(z) ) {
match = map.get(z); // map[z]; on object
break;
}
}
Run Code Online (Sandbox Code Playgroud)
我发现的最近的东西是使用.keys()
let iter = map.keys();
while(!iter.next().done) {
if(foo.match(iter.value)) {
match = map.get(iter.value);
break
}
}
Run Code Online (Sandbox Code Playgroud) go ×2
ruby ×2
arrays ×1
break ×1
c# ×1
containers ×1
delphi ×1
dictionary ×1
flutter ×1
freepascal ×1
javascript ×1
jsonb ×1
kubernetes ×1
ld ×1
loops ×1
postgresql ×1
rancher ×1
slice ×1
sql-update ×1
string ×1