Skip to content

Instantly share code, notes, and snippets.

View croisillon's full-sized avatar
😴
AlwayZzz...

Croisillon T. Sign croisillon

😴
AlwayZzz...
View GitHub Profile
#include "cmpmc.h"
int cmpmc_init(mpmc_bounded_queue_t *q, size_t buf_size) {
if (q == NULL || buf_size < 2 || (buf_size & (buf_size - 1)) != 0) return -1;
// Выделяем память для ячеек буфера
cell_t *alloc_buf = calloc(buf_size, sizeof(cell_t));
if (alloc_buf == NULL)
return -1;
@croisillon
croisillon / Golang_prometheus.md
Last active March 14, 2024 10:54
Golang Prometheus metrics

Prometheus

Для сбора метрик с использованием Golang используются библиотеки из репозитория prometheus

// библиотека со всеми наборами метрик
import "github.com/prometheus/client_golang/prometheus"
  • Counter (счетчик) - хранит значения, которые увеличиваются с течением времени
@croisillon
croisillon / install-instantclient.sh
Last active August 1, 2023 09:49
Oracle instantclient installer
#!/usr/bin/env bash
ROOT=/opt/oracle
if [ ! -e $ROOT ]; then
mkdir -p $ROOT
fi
LIBS=instanclient_basic_lib.zip
if [ ! -e $LIBS ]; then
wget -O $LIBS https://github.com/bumpx/oracle-instantclient/raw/master/instantclient-basic-linux.x64-12.1.0.2.0.zip
@croisillon
croisillon / moy.pl
Last active December 3, 2025 06:32
Number of days in the month of the year
sub days_inmonth_inyear {
my ( $x, $y ) = @_;
return 28 + ( ( $x + int( $x / 8 ) ) % 2 ) + 2 % $x + int(
( 1
+ ( 1 - ( $y % 4 + 2 ) % ( $y % 4 + 1 ) )
* ( ( $y % 100 + 2 ) % ( $y % 100 + 1 ) )
+ ( 1 - ( $y % 400 + 2 ) % ( $y % 400 + 1 ) )
) / $x
) + int( 1 / $x ) - int(
( ( 1 - ( $y % 4 + 2 ) % ( $y % 4 + 1 ) )
@croisillon
croisillon / javascript.translit.js
Last active March 3, 2025 09:44
JavaScript translater russian to translit
function rus_to_latin ( str ) {
var ru = {
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd',
'е': 'e', 'ё': 'e', 'ж': 'j', 'з': 'z', 'и': 'i',
'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o',
'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'ch', 'ш': 'sh',
'щ': 'shch', 'ы': 'y', 'э': 'e', 'ю': 'u', 'я': 'ya'
}, n_str = [];