Skip to content

Instantly share code, notes, and snippets.

View mikhailov's full-sized avatar

Anatoly Mikhaylov mikhailov

View GitHub Profile
@mikhailov
mikhailov / sysctl.conf
Last active January 3, 2016 19:09
OS X Server TCP/IP tuning
net.inet.tcp.sack=1
net.inet.tcp.rfc1323=1
net.inet.tcp.recvspace=1048576
net.inet.udp.recvspace=1048576
net.inet.tcp.sendspace=1048576
net.inet.tcp.mssdflt=1460
net.inet.tcp.win_scale_factor=8
module ActionDispatch
class Reloader
def call(env)
if env['PATH_INFO'].include?(Rails.application.config.assets.prefix)
@app.call(env)
else
@validated = @condition.call
prepare!
@mikhailov
mikhailov / gist:3fd58bd21ecc5f7220cc
Created September 26, 2014 07:49
Set specific Ruby version on CentOS
#/bin/bash -e
RUBY_VERSION=2.0.0
if [ "$RUBY_VERSION" == '2.0.0' ]; then
yum -y install ruby20 rubygems20 ruby-devel
alternatives --set ruby /usr/bin/ruby2.0
elif [ "$RUBY_VERSION" == '1.9.3' ]; then
yum -y install ruby19 rubygems19 ruby19-devel
@mikhailov
mikhailov / Vagrantless
Last active October 15, 2017 09:37
Vagrantless (draft), tested on OS X only.
# This the bash script to handle up-and-runnig VM created through Vagrant
#!/usr/bin/env bash
# PRIVATE: error level message
error_message () {
echo "$(tput setaf 1)ERROR: $1$(tput sgr0)"
}
@mikhailov
mikhailov / deploy.rb
Created July 26, 2012 09:14
capistrano prettify
# standard capistrano config goes here....
# Put the maintenance screen if DB migrations take in place only
before "deploy", "deploy:delayed_job:stop"
before "deploy:migrations", "deploy:delayed_job:stop"
after "deploy:update_code", "deploy:symlink_shared", "deploy:assets_compress"
before "deploy:migrate", "deploy:web:disable", "deploy:db:backup"
after "deploy", "newrelic:notice_deployment", "deploy:cleanup", "deploy:delayed_job:restart"
@mikhailov
mikhailov / nginx.conf
Last active October 7, 2018 10:15
Jira connection optimised (Nio enabled, gzip disabled on Tomcat, but enabled on Reverse proxy side, Proxy with HTTP 1.1 keep-alive, SSL offload, SPDY). Nginx 1.5.10+ recommended.
echo 'events {
worker_connections 1024;
}
error_log /usr/local/Cellar/nginx/1.5.8/error.log;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
@mikhailov
mikhailov / datadog_apm_sql_time.rb
Last active October 30, 2019 11:49
Datadog APM instrumentation to have SQL Time for every event
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
span = Datadog.tracer.active_span
payload = event.payload
if span && payload.key?(:db_runtime)
db_runtime = payload[:db_runtime].to_f.round(3)
span.set_tag('database.sql_time', db_runtime)
end
end
@mikhailov
mikhailov / mysql_process_list_to_stdout.sh
Last active January 19, 2020 13:04
MySQL Process List redirect to STDOUT
#!/bin/bash
set -ex
# Inject APM Trace ID (part of SQL query comment) to a Log event
# https://docs.datadoghq.com/tracing/advanced/connect_logs_and_traces/?tab=ruby
# Input: {"command": "Query", "current_statement": "SELECT ... /* 4572859165692197980 */"}
# Output: {"process_list": {"current_statement": "SELECT ... /* 4572859165692197980 */"}, "dd": {"trace_id": 4572859165692197980}}
function inject_trace_id() {
trace_id=$(echo "$1" |grep -Eo '/\* [0-9]{16,20} \*/' | awk '{print $2}')
#!/bin/bash -e
curl -O http://ftp.heanet.ie/pub/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
export VM="MASTER"
export VMDISK="$VM-disk"
export REDHAT_IMAGE="/Users/user/Downloads/CentOS-7.0-1406-x86_64-Minimal.iso"
VBoxManage hostonlyif create
VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.20.1
@mikhailov
mikhailov / ruby_gc.sh
Created March 11, 2011 10:33
Ruby’s GC Configuration
- http://www.coffeepowered.net/2009/06/13/fine-tuning-your-garbage-collector/
- http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration
article’s settings: ("spec spec" took 17-23!sec)
export RUBY_HEAP_MIN_SLOTS=1250000
export RUBY_HEAP_SLOTS_INCREMENT=100000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=30000000
export RUBY_HEAP_FREE_MIN=12500