Skip to content

Instantly share code, notes, and snippets.

View slimsag's full-sized avatar
😸
Herding cats

Stephen Gutekanst slimsag

😸
Herding cats
View GitHub Profile
error(compilation): clang failed with stderr: zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
In file included from C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libcxxabi\src/cxa_aux_runtime.cpp:14:
In file included from C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libcxx\include\typeinfo:75:
C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libc\include\any-windows-any\vcruntime_typeinfo.h:121:13: error: target of using declaration conflicts with declaration already in scope
C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libc\include\any-windows-any\vcruntime_typeinfo.h:69:7: note: target of using declaration
C:\Users\slimsag\Desktop\zig\zig-out\lib\zig\libcxxabi\include\cxxabi.h:30:27: note: conflicting declaration
error(compilation): clang failed with stderr: zig: warning: argument unused during compilation: '-nostdinc++' [-Wunused-command-line-argument]
zig: warning:
@slimsag
slimsag / regex.go
Created January 23, 2020 05:46
Go | Golang | Regex replace all byte submatches | regexp.ReplaceAllSubmatchFunc |
// replaceAllSubmatchFunc is the missing regexp.ReplaceAllSubmatchFunc; to use it:
//
// pattern := regexp.MustCompile(...)
// data = replaceAllSubmatchFunc(pattern, data, func(groups [][]byte) [][]byte {
// // mutate groups here
// return groups
// })
//
// This snippet is MIT licensed. Please cite by leaving this comment in place. Find
// the latest version at:
@slimsag
slimsag / cadvisor_hack.md
Last active November 2, 2021 11:16
cAdvisor's missing `container_restart_count` metric

Problem: cAdvisor's missing container_restart_count metric

cAdvisor doesn't monitor container restarts, but it does pass through / expose the Docker label container_restart_count to you.

Unfortunately, being a label, you cannot really monitor it. And it looks like this isn't something cAdvisor plans to support soon, as the issue has been closed.

Solution

I am not proud of this and hope cAdvisor will support this more easily in the future, but, it does work well. Here is a Prometheus rule you can use to define this metric.

postgres=# SELECT sp.series_id, sp.time AS interval_time, SUM(value) as value, null as metadata
postgres-# FROM series_points sp JOIN repo_names rn ON sp.repo_name_id = rn.id
postgres-# WHERE series_id='s:7390958469D3357348D1873F0D7EE7D1130023CDE9AE614F6F945ACEBF4DD36D'
postgres-# GROUP BY sp.series_id, interval_time, sp.repo_name_id
postgres-# ORDER BY sp.series_id, interval_time, sp.repo_name_id DESC;
series_id | interval_time | value | metadata
--------------------------------------------------------------------+------------------------+-------+----------
s:7390958469D3357348D1873F0D7EE7D1130023CDE9AE614F6F945ACEBF4DD36D | 2020-09-01 00:00:00+00 | 0 |
s:7390958469D3357348D1873F0D7EE7D1130023CDE9AE614F6F945ACEBF4DD36D | 2020-09-01 00:00:00+00 | 0 |
s:7390958469D3357348D1873F0D7EE7D1130023CDE9AE614F6F945ACEBF4DD36D | 2020-09-01 00:00:00+00 | 0 |
$ lldb -- /Users/slimsag/Desktop/hexops/zig/build/bin/zig build-exe /Users/slimsag/Desktop/hexops/zig/src/main.zig /Users/slimsag/Desktop/hexops/zig/build/zigcpp/libzigcpp.a /usr/local/opt/llvm/lib/libclangFrontendTool.a /usr/local/opt/llvm/lib/libclangCodeGen.a /usr/local/opt/llvm/lib/libclangFrontend.a /usr/local/opt/llvm/lib/libclangDriver.a /usr/local/opt/llvm/lib/libclangSerialization.a /usr/local/opt/llvm/lib/libclangSema.a /usr/local/opt/llvm/lib/libclangStaticAnalyzerFrontend.a /usr/local/opt/llvm/lib/libclangStaticAnalyzerCheckers.a /usr/local/opt/llvm/lib/libclangStaticAnalyzerCore.a /usr/local/opt/llvm/lib/libclangAnalysis.a /usr/local/opt/llvm/lib/libclangASTMatchers.a /usr/local/opt/llvm/lib/libclangAST.a /usr/local/opt/llvm/lib/libclangParse.a /usr/local/opt/llvm/lib/libclangSema.a /usr/local/opt/llvm/lib/libclangBasic.a /usr/local/opt/llvm/lib/libclangEdit.a /usr/local/opt/llvm/lib/libclangLex.a /usr/local/opt/llvm/lib/libclangARCMigrate.a /usr/local/opt/llvm/lib/libclangRewriteFrontend.a /usr/
$ zig build --prefix $(pwd)/stage2 -Denable-llvm --search-prefix "$(brew --prefix llvm)"
warning(link): library not found for '-lLLVMWindowsManifest'
warning(link): Library search paths:
warning(link): /usr/local/opt/llvm/lib
warning(link): /usr/local/opt/llvm/lib
warning(link): /usr/lib
warning(link): /usr/local/lib
warning(link): library not found for '-lLLVMXRay'
warning(link): Library search paths:
warning(link): /usr/local/opt/llvm/lib
$ zig build --prefix $(pwd)/stage2 -Denable-llvm --search-prefix "$(brew --prefix llvm)"
warning(link): library not found for '-lLLVMWindowsManifest'
warning(link): Library search paths:
warning(link): /usr/local/opt/llvm/lib
warning(link): /usr/local/opt/llvm/lib
warning(link): /usr/lib
warning(link): /usr/local/lib
warning(link): library not found for '-lLLVMXRay'
warning(link): Library search paths:
warning(link): /usr/local/opt/llvm/lib
/Users/slimsag/Desktop/hexops/zig/build/lib/zig/std/fmt.zig:606:17: error: Unable to format type 'anyframe'
else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"),
^
/Users/slimsag/Desktop/hexops/zig/build/lib/zig/std/fmt.zig:558:35: note: called from here
try formatType(elem, actual_fmt, options, writer, max_depth - 1);
^
/Users/slimsag/Desktop/hexops/zig/build/lib/zig/std/fmt.zig:511:31: note: called from here
try formatType(@field(value, f.name), ANY, options, writer, max_depth - 1);
^
/Users/slimsag/Desktop/hexops/zig/build/lib/zig/std/fmt.zig:511:31: note: called from here