Skip to content

Instantly share code, notes, and snippets.

View skatkov's full-sized avatar
🏠
Working from home

Stanislav (Stas) Katkov skatkov

🏠
Working from home
View GitHub Profile
name: CI
on: push
jobs:
brakeman:
name: Brakeman
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
@hschne
hschne / rate_limit.rb
Created January 11, 2024 17:02
Leaky Bucket Rate Limiter in Ruby
frozen_string_literal: true
# A leaky bucket rate limiter for Ruby
#
# @see https://www.mikeperham.com/2020/11/09/the-leaky-bucket-rate-limiter/
# @see https://en.wikipedia.org/wiki/Leaky_bucket
class RateLimit
class Error < StandardError
attr_accessor :retry_in
@searls
searls / .solargraph.yml
Last active August 2, 2023 09:14 — forked from DRBragg/.solargraph.yml
My config with steps to use solargraph for Rails projects in VS Code (WIP)
---
include:
- ".solargraph_definitions.rb"
- "app/**/*.rb"
- "config/**/*.rb"
- "lib/**/*.rb"
exclude:
- test/**/*
- vendor/**/*
- ".bundle/**/*"
# Rails production setup via SQLite3 made durable by https://litestream.io/
# Copy this to Dockerfile on a fresh rails app. Deploy to fly.io or any other container engine.
#
# try locally: docker build . -t rails && docker run -p3000:3000 -it rails
#
# in production you might want to map /data to somewhere on the host,
# but you don't have to!
#
FROM ruby:3.0.2
# frozen_string_literal: true
require 'benchmark'
require 'benchmark/ips'
require 'benchmark/memory'
require 'csv'
N_NUMBER_OF = 100_000
ary = Array.new(N_NUMBER_OF) { ['one', 'two', 'three', 'four', 'five', 'six'] }
@mkaschenko
mkaschenko / git-churn.rb
Last active February 11, 2021 16:43
Provides churn statistics (frequency of change) for git repositories
#!/usr/bin/env ruby
# frozen_string_literal: true
# This program modifies the original output of git-churn program https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn.
# It highlights current project files in green colour.
unless Kernel.system('command -v git-churn &> /dev/null')
STDOUT.puts("Install git-churn first. See details at https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn")
Kernel.exit
end
@aleksandr-kotlyar
aleksandr-kotlyar / .gitlab-ci.yml
Last active April 19, 2022 14:53
slack text notifications
SLACK_TEXT_START: 'Pipeline <$CI_PIPELINE_URL|$CI_PIPELINE_ID> _has started_ *$CI_PIPELINE_SOURCE* job <$CI_JOB_URL|$CI_JOB_ID> on *$ENVIRONMENT* _at branch_ *<$CI_PROJECT_URL/commit/$CI_COMMIT_SHA|$CI_COMMIT_REF_NAME>*'
SLACK_TEXT_FINISH: 'Pipeline <$CI_PIPELINE_URL|$CI_PIPELINE_ID> _has finished_ *$CI_PIPELINE_SOURCE* job <$CI_JOB_URL|$CI_JOB_ID> on *$ENVIRONMENT* _at branch_ *<$CI_PROJECT_URL/commit/$CI_COMMIT_SHA|$CI_COMMIT_REF_NAME>* _and generated_ *<$ALLURE_DIR|Allure Reports>*'
#####################################
# Custom Slack POST-message report #
#####################################
slack_notification:
script:
- >
curl
@tkadlec
tkadlec / perf-diagnostics.css
Last active June 8, 2023 17:47
CSS used to highlight potential performance issues
:root {
--violation-color: red; /* used for clear issues */
--warning-color: orange; /* used for potential issues we should look into */
}
/* IMAGES */
/*
* Lazy-Loaded Images Check
* ====
@janklimo
janklimo / Output.txt
Created December 10, 2020 08:59
Ruby: try vs &.
"=== Memory when using `try` ==="
Total allocated: 40 bytes (1 objects)
Total retained: 0 bytes (0 objects)
allocated memory by gem
-----------------------------------
40 other
allocated memory by file
-----------------------------------
@kimihito
kimihito / Dockerfile.prod
Last active December 24, 2022 19:00
Using Fullstaq Ruby on Heroku
# base dockerfile from https://github.com/evilmartians/terraforming-rails/blob/567566348a6a9893e10b9f857f1e5e58ba581b41/examples/dockerdev/.dockerdev/Dockerfile
# See explanation below
ARG RUBY_VERSION
FROM quay.io/evl.ms/fullstaq-ruby:$RUBY_VERSION-jemalloc-buster-slim as builder
ARG PG_MAJOR
ARG NODE_MAJOR
ARG BUNDLER_VERSION