Skip to content

Instantly share code, notes, and snippets.

@zarmin
zarmin / create-datadog-users-mssql.sql
Last active June 26, 2024 08:31
Create datadog user for each database in MSSQL
-- https://docs.datadoghq.com/database_monitoring/setup_sql_server/gcsql/?tab=linuxhost&site=eu
DECLARE @databaseName NVARCHAR(255)
DECLARE @sql NVARCHAR(MAX)
DECLARE db_cursor CURSOR FOR
SELECT name
FROM sys.databases
WHERE state_desc = 'ONLINE'
AND name NOT IN ('master', 'tempdb', 'model', 'msdb')
@zarmin
zarmin / provide-network-to-host-ssh.md
Created January 23, 2023 13:59
Provide network to host via SSH
# first term
tinyproxy -d

# second term
ssh -R 8888:127.0.0.1:8888  <ssh host>

# after connect
# proxy env var
export HTTP_PROXY=http://127.0.0.1:8888
@zarmin
zarmin / is_integer.c
Last active January 23, 2023 13:59
is double an integer
#include <inttypes.h>
int isInteger(double input) {
uint64_t x = *((uint64_t*)&input);
if ((x & 0x7fffffffffffffffULL) == 0)
return 1;
int i;
for (i = 52; i >= 0 && !(x & (1ULL << (52-i))); i--);
return (int)(((x & 0x7ff0000000000000ULL) >> 52) - 1023) >= i;
}
@zarmin
zarmin / RDRAND.md
Created October 14, 2020 08:25
RDRAND

RDRAND

Check if supported

From shell

cat /proc/cpuinfo | fgrep rdrand
@zarmin
zarmin / test.c
Created June 18, 2019 00:30
hanwen/go-fuse, nfs, readdir EINVAL error reproduce
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/syscall.h>
@zarmin
zarmin / docker_xfs_quota.sh
Last active March 26, 2018 23:00
Docker XFS Quota
#!/bin/bash -e
# use as: ./docker_xfs_quota.sh <container id>
# requires xfsprogs, jq, docker
DIFF_DIR_PATH="$(docker inspect $1 | jq -r '.[0].GraphDriver.Data.UpperDir')"
PQUOTA_PROJECT_ID="$(xfs_io -c lsproj $DIFF_DIR_PATH | sed 's/projid = //')"
xfs_quota -x -c "quota -h -p ${PQUOTA_PROJECT_ID}" /var/lib/docker/