Skip to content

Instantly share code, notes, and snippets.

View mikhailov's full-sized avatar

Anatoly Mikhaylov mikhailov

View GitHub Profile
@mikhailov
mikhailov / qu.rb
Last active September 20, 2015 19:47
quick union
class QU
attr_reader :array
def initialize(array)
@array = array
end
def union(p,q)
return if p == q
@array[root(p)] = root(q)
@mikhailov
mikhailov / uf.rb
Last active September 20, 2015 18:54
union find
class UF
attr_reader :array
def initialize(array)
@array = array
end
def union(p,q)
return if p == q
@mikhailov
mikhailov / flattenizer.rb
Last active August 29, 2015 14:26
flatten an array of arbitrarily nested arrays of integers into a flat array of integers (can't use Array#flatten built-in method)
class Flattenizer
def initialize(params)
if params.empty?
raise ArgumentError, 'Data set is empty'
end
if !params.is_a?(Array)
raise TypeError, 'Data set is not an array'
end
@input_array = params
#!/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 / 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
SET @db_name = '***';
SELECT
TBname,
CONCAT(LPAD(REPLACE(FORMAT(B.DSize/POWER(102,pw),3),',',''),17,' '),' ', SUBSTR(' KMGTP',pw,1),'B') "Data Size",
CONCAT(LPAD(REPLACE(FORMAT(B.ISize/POWER(102,pw),3),',',''),17,' '),' ', SUBSTR(' KMGTP',pw,1),'B') "Index Size",
CONCAT(ROUND(B.ISize * 100 / B.DSize), ' %') "Percentage",
CONCAT(LPAD(REPLACE(FORMAT(B.TSize/POWER(102,pw),3),',',''),17,' '),' ', SUBSTR(' KMGTP',pw,1),'B') "Table Size"
FROM
(SELECT table_name TBname, data_length DSize, index_length ISize, data_length+index_length TSize
@mikhailov
mikhailov / gist:9639593
Last active November 10, 2023 22:04
Nginx S3 Proxy with caching
events {
worker_connections 1024;
}
http {
default_type text/html;
access_log /dev/stdout;
sendfile on;
keepalive_timeout 65;
@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 / 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
@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)"
}