Skip to content

Instantly share code, notes, and snippets.

View ixti's full-sized avatar
😂
forever blowing bubbles

Alexey Zapparov ixti

😂
forever blowing bubbles
View GitHub Profile
# frozen_string_literal: true
require "concurrent"
module Sidekiq
module Throttled
class ExpirableSet
attr_reader :default_ttl
def initialize(default_ttl:)
[Unit]
Description=Twingate Remote Access Client
Wants=network-pre.target
After=network-pre.target NetworkManager.service systemd-resolved.service
[Service]
ExecStart=/usr/sbin/twingated /etc/twingate/config.json
Restart=on-failure
RestartSec=5s
RuntimeDirectory=twingate
@ixti
ixti / redis_workbench.rb
Last active May 10, 2023 23:25
Redis workbench (supports redis-rb only)
class RedisWorkbench
attr_accessor :logger
def initialize(redis_pool: ::Sidekiq.redis_pool, count: 1000, logger: Logger.new($stdout))
@redis_pool = redis_pool
@count = count.to_i
@logger = logger
end
# @example with block
@ixti
ixti / aye_or_nay.sh
Last active January 26, 2023 14:57
Shell helper function to show yes/no prompt
function aye_or_nay() {
local response
local result
while [[ -z "${result:-}" ]]; do
echo -n "$1 (y/n) "
read response
case "$(echo "${response}" | tr '[:upper:]' '[:lower:]')" in
aye | yes | y )
class CarExperiment < ApplicationExperiment
class CappedRollout < Gitlab::Experiment::Rollout
def execute_assignment
assignments = Users::ExperimentAssignment.where(experiment_name: @experiment.name).group(:variant_name).count
variants = %i[polo golf touran].select { |variant_name| assignments[variant_name.to_s].to_i < 5000 }
return if variants.blank?
variants[Digest::MD5.hexdigest(id).to_i(16) % variants.size]
end
end
require "active_support/time"
require "timecop"
Timecop.safe_mode = true
RSpec.configure do |config|
config.around(:frozen_time) do |ex|
time =
case (value = ex.metadata[:frozen_time])
when true then Time.current.floor(0)
@ixti
ixti / twingate-1.0.37.35359.1.ebuild
Created July 4, 2022 22:58
net-vpn/twingate-1.0.37.35359.1
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit rpm bash-completion-r1
DESCRIPTION="Crap"
HOMEPAGE="https://www.twingate.com/"
SRC_URI="https://packages.twingate.com/rpm/files/ver_1lMD38/twingate-x86_64.rpm -> ${P}.rpm"
@ixti
ixti / sidekiq-queue-filter.rb
Last active May 19, 2022 16:31
Sidekiq: queue filtering
module SidekiqQueueFilterV3
class Observer
def initialize(frequency: 1000)
@frequency = frequency.to_i
@buffer = 0
@stats = Hash.new(0)
end
def call(event)
@buffer += 1
#!/usr/bin/env bash
if [ -n "$1" ] && [ -n "$2" ]; then
LS_COLORS="$(vivid --database "$1" generate "$2")"
elif [ -n "$1" ]; then
LS_COLORS="$(vivid generate "$1")"
else
echo "USAGE: $0 [database] theme" >&2
exit 1
fi
#!/usr/bin/env ruby
require "pathname"
require "yaml"
filetypes = File.open("config/filetypes.yml", "r") { |io| YAML.safe_load(io) }
# core types will be processed manually
filetypes.delete("core")