Skip to content

Instantly share code, notes, and snippets.

View wirwolf's full-sized avatar

Andru Cherny wirwolf

View GitHub Profile
@wirwolf
wirwolf / backup.sh
Created December 16, 2023 18:11
gitlab-utils.sh
#!/usr/bin/env bash
set -eu
export BACKUP_FOLDER=/opt/gitlab/data/backups
export CONTAINER_NAME=gitlab
echo "[$(date)] remove old backup"
find ${BACKUP_FOLDER} -name '*_gitlab_backup.tar' -delete -print
rm -v ${BACKUP_FOLDER}/gitlab_backup.tar.sha512sum || true
rm -v ${BACKUP_FOLDER}/gitlab_backup.log || true
@wirwolf
wirwolf / example.cpp
Last active November 13, 2023 07:44
Arduino AsyncWebServer examples
server.on("/test", HTTP_GET, [](AsyncWebServerRequest *request){
ArduinoJson::StaticJsonDocument<200> doc;
// Add values in the document
//
doc["sensor"] = "gps";
doc["time"] = 1351824120;
// Add an array.
//
@wirwolf
wirwolf / ecosystem.json
Created June 14, 2018 20:13
pm2 ecosystem.json config example
{
"apps": [
{
/* General */
"name": "my-api", /* (string) application name (default to script filename without extension) */
"script": "index.js", /* (string) script path relative to pm2 start */
"cwd": "/var/www/", /* (string) the directory from which your app will be launched */
"args": "-a 13 -b 12", /* (string) string containing all arguments passed via CLI to script */
"interpreter": "/usr/bin/python", /* (string) interpreter absolute path (default to node) */
"interpreter_args": "--harmony", /* (string) option to pass to the interpreter */
describe('Helpers.Quantity', () => {
it('should generate quantities', () => {
expect(scalarToQuantity(2 / 1_000_000_000, 'n')).to.equal('2n');
expect(scalarToQuantity(3 / 1_000_000, 'u')) .to.equal('3u');
expect(scalarToQuantity(0.1, 'm')) .to.equal('100m');
expect(scalarToQuantity(BigInt(3000), 'k')) .to.equal('3k');
expect(scalarToQuantity(BigInt(3 * 1000 * 1000), 'M')) .to.equal('3M');
expect(scalarToQuantity(BigInt(3 * 1000 * 1000 * 1000), 'G')) .to.equal('3G');
expect(scalarToQuantity(BigInt(5 * 1000 * 1000 * 1000) * BigInt(1000), 'T')) .to.equal('5T');
expect(scalarToQuantity(BigInt(3 * 1000 * 1000 * 1000) * BigInt(1000 * 1000), 'P')) .to.equal('3P');
function findSuffix(quantity: string): string {
let ix = quantity.length - 1;
while (ix >= 0 && !/[\.0-9]/.test(quantity.charAt(ix))) {
ix--;
}
return ix === -1 ? '' : quantity.substring(ix + 1);
}
function quantityToScalar(quantity: string): number | bigint {
if (!quantity) {
pvresize --setphysicalvolumesize 400G /dev/mapper/nvme0n1p3_crypt
@wirwolf
wirwolf / resource.yaml
Created December 27, 2022 07:53
prom error
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
annotations:
meta.helm.sh/release-name: rancher-monitoring
meta.helm.sh/release-namespace: cattle-monitoring-system
creationTimestamp: '2022-12-20T12:02:36Z'
generation: 3
labels:
app: rancher-monitoring-prometheus
#!/bin/bash
trap trap_exit SIGINT
trap trap_exit SIGQUIT
trap trap_exit SIGTSTP
trap_exit() {
echo "trap signal: sleep 3 and exit"
sleep 3
echo "Bye..."
exit
@wirwolf
wirwolf / _helpers.tpl
Last active September 7, 2022 07:14
hpa
{{/* vim: set filetype=mustache: */}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "workers.hpa_metric_name" -}}
{{- printf "%s-%s" .Release.Namespace .Release.Name | replace "+" "_" | replace "-" "_" | trunc 63 -}}
{{- end -}}
apiVersion: v1
kind: Pod
metadata:
annotations:
imageHash: sha256:f885a590d7d3123df58bd23392e40daa3c951aae63f3e3d457ee43efffb49844
creationTimestamp: "2022-06-29T12:45:22Z"
generateName: landings-fake-php-fpm-77f788b5cb-
labels:
app.kubernetes.io/instance: landings-fake-php-fpm
app.kubernetes.io/name: app-php-fpm-nginx