Skip to content

Instantly share code, notes, and snippets.

View kigster's full-sized avatar
:octocat:
Pushing AI automation into production.

Konstantin Gredeskoul kigster

:octocat:
Pushing AI automation into production.
View GitHub Profile
@kigster
kigster / cursor-extension-importer.sh
Created January 22, 2025 02:59
Import VSCode Extensions into Cursor via CLI
#!/usr/bin/env bash
# vim: ft=bash
#
# © 2025 Konstantin Gredeskoul
# http://github.com/kigster | https://kig.re
#
# This script allows you to export the list of your VSCode
# extensions and import them into, eg. Cursor IDE. Or the
# other way around. By the default the script continues on
# import errors because there are typically quite a few.
@kigster
kigster / ec2-bench.sh
Last active January 8, 2025 20:37
AWS Instance Benchmark using sysbench
#!/usr/bin/env bash
# vim: ft=bash
# Uses sysbench on Ubuntu to run CPU, RAM and File IO Tests
# Saves the output into "result-for-<instance-type>-<date>-<time>.txt
#
# You can run this as follows without downloading:
# curl -fsSL https://gist.githubusercontent.com/kigster/3869409f17739461f9d1fb7e0aa5022c/raw | bash
line() {
echo -e "\e[0;33m———————————————————————————————————————————————————————————————————————\e[0m"
@kigster
kigster / ruby-install
Last active February 18, 2025 20:20
Ruby Install Minimal script for MacOS and Linux. You can use it to install a recent Ruby using `rbenv` and `ruby-build`, with Jemalloc & YJIT enabled. Run it like so: `bash -c "$(curl -fsSL https://bit.ly/ruby-install-0-2-1)" -- 3.4.1`
#!/usr/bin/env bash
# vim: ft=bash
#
# © 2025 Konstantin Gredeskoul <kig AT kig.re>
# All rights reserved.
# MIT License.
#
# This script uses rbenv/ruby-build to install Ruby on OS-X or Linux. It configures
# Ruby build flags in such a way to ensure Ruby is linked with libjemalloc (which
# reduces the memory by half) and YJIT enabled. It has been tested on both Linux and
@kigster
kigster / check-my-rubies-for-jemalloc.sh
Last active October 29, 2024 19:00
This script will check all of your rbenv and system built-rubies for presence of Jemalloc library
#!/usr/bin/env bash
# vim: ft=bash
#
# © 2024 Konstantin Gredeskoul <kig AT kig.re>
#
# How to use this:
# curl -fsSL https://bit.ly/rb-jemalloc-check | bash
export rc=/tmp/ruby-check
curl -fsSL -o $rc "https://raw.githubusercontent.com/kigster/bashmatic/refs/heads/main/bin/ruby-check"
@kigster
kigster / ruby-install.sh
Last active October 29, 2024 19:36
Ruby Installer via RBENV on Linux & Mac OS-X (with jemalloc & yjit enabled)
#!/usr/bin/env bash
# vim: ft=bash
#
# This Gist is about installing any version of Ruby using rbenv on Linux or MacOS
# with Jemalloc and YJIT enabled.
#
# To install a ruby run the following command (this will install the ruby version
# defined in the .ruby-version file in the current directory)
#
# curl -fsSL https://bit.ly/rb-rbenv-install | bash
@kigster
kigster / logging_module.rb
Last active July 30, 2024 19:04
Ruby pattern for including a logging module everywhere you want. Just add “include Logging” at the top and you get both class and instance methods for logging such as #info, #debug, #error, #warn, #fatal. The threading at the bottom shows that the Logger is thread-safe and can be used without Mutexes.
# (c) 2024 Konstantin Gredeskoul
# Under the MIT License
#
# This gist documents a frequently thed pattern of decorating multiple classes with Logging methods
# by sharing just one Logger typically at the top of the module namespace (Application) in this case.
# If the concurrency issues come up, each class can be given its own logger, or perhaps the Logging moduloe
# might have decorators for each of the logging methods (eg #info, #debug) by using a Mutex.
#
# The output of this Ruby Code should be as follows:
@kigster
kigster / memcached-test.rb
Created November 8, 2023 20:01
Memcached Multi-Get vs Single Get
# Gemfile
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.
gem 'rails', '>= 7.0.4.3'
gem "dalli"
gem "rspec"
gem "rspec-its"
gem "rspec-rails"
gem "awesome_print"
-- This file requires a local SQL file named "json_table_columns.csv" to have two columns:
-- [ "Table", "Column" ]
-- It then loops over records in this table computing the total size of the column in each table,
-- the average size of the column in that table, and finally the percentage that column occupies relative
-- to the entire table (including its indexes).
-- First we import the data
BEGIN;
drop table if exists JSON_TABLE_COLUMNS;
@kigster
kigster / ruby-memory-env.sh
Created April 23, 2022 01:34
Ruby 2+ environment variables to tune GC and memory bloat to a minimum on large apps
# Discourse Settings
export RUBY_GC_HEAP_INIT_SLOTS=997339
export RUBY_GC_HEAP_FREE_SLOTS=626600
export RUBY_GC_HEAP_GROWTH_FACTOR=1.03
export RUBY_GC_HEAP_GROWTH_MAX_SLOTS=88792
export RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=2.4
export RUBY_GC_MALLOC_LIMIT=34393793
export RUBY_GC_MALLOC_LIMIT_MAX=41272552
export RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.32
export RUBY_GC_OLDMALLOC_LIMIT=39339204
@kigster
kigster / Makefile
Last active November 19, 2022 06:08
Makefile for Exporting and Restoring VSCode Extensions
# © 2019-2021 Konstantin Gredeskoul, MIT License.
# vim: ft=make
#
# Place this file anywhere.
#
# 1. To create a backup of your vscode settings, keybindings and extensions, run
# $ make save
# This backs it all up to your ~/Documents/VSCode folder.
#
# 2 To restore VSCode configuration: