Skip to content

Instantly share code, notes, and snippets.

View ochaton's full-sized avatar

Vladislav Grubov ochaton

View GitHub Profile
@ochaton
ochaton / aws.sh
Created March 11, 2026 09:32
MacOS version to hijack aws sso login (bash script, put it into $HOME/bin/aws or somewhere visible)
#!/bin/bash
set -euo pipefail
REAL_AWS="/opt/homebrew/bin/aws"
is_help() {
local arg
for arg in "$@"; do
case "$arg" in
help|-h|--help) return 0 ;;
@ochaton
ochaton / nullable_test.go
Last active March 4, 2026 22:25
nullable jsons
package test
import (
"encoding/json"
"testing"
"time"
)
func Some[T any](value T) *T {
return &value
@ochaton
ochaton / index.html
Created November 16, 2025 10:31
quiz-site
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Тестики :)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="page">
func partition(nums1 []int, nums2 []int) (int, int) {
n1 := len(nums1)
n2 := len(nums2)
half := (n1+n2) >> 1
// n1 ≤ n2 => n1 ≤ half=(n1+n2)>>1 ≤ n2
// i want to have left part ≤ right part
// now, I split nums1 and nums2 in a way such as:
// [0;m1)+[m1;n1+1) and [0;m2)+[m2;n2+1)
func listenUnix(socket_path string) (*net.UnixListener, error) {
addr, err := net.ResolveUnixAddr("unix", socket_path)
if err != nil {
return nil, err
}
fi, err := os.Lstat(socket_path)
switch {
case os.IsNotExist(err):
return net.ListenUnix("unix", addr)
@ochaton
ochaton / base.lua
Created May 1, 2025 12:56
base.lua - compact base oop, inheritance is a main banger
local setmetatable, type, pairs, rawget = setmetatable, type, pairs, rawget
local copy do
pcall(require, 'table.new')
local table_new = rawget(table, 'new') or function(_, _) return {} end
function copy(t)
local new_t = table_new(0, 8)
for k, v in pairs(t) do new_t[k] = v end
return new_t
@ochaton
ochaton / core_modules.pl
Created April 9, 2025 02:24
Perl script which prints out which core modules are installed with their help
use strict;
use warnings;
use feature 'say';
use Module::CoreList;
use Pod::Simple::SimpleTree;
use List::Util qw(first);
# 1 - only standard level modules
# 2 - mostly all packages
# 3 - subpackages of packages

Weird EV-loop behaviour

I've recently discovered weird behaviour of EV-loop timers.

First in Tarantool, and now in Perl libev.

Subj:

When asking EV-loop to sleep for 1ms, it does 1.2ms when requesting to sleep for 2ms, it does 2.4ms,

@ochaton
ochaton / cluster-config-json-schema.lua
Last active September 6, 2024 11:49
Generate JSON schema for Tarantool's cluster configuration by @Totktonada
#!/usr/bin/env tarantool
local json = require('json')
local cluster_config = require('internal.config.cluster_config')
local scalars = {}
scalars.string = {
jsonschema = {
type = 'string',
@ochaton
ochaton / lib.rs
Created September 5, 2024 20:04
Rust stored Proc registration without Lua
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use tarantool::{self, session, tuple::Encode};
use mlua::Lua;
#[tarantool::proc]
fn add(left: i64, right: i64) -> i64 {
left + right
}