Skip to content

Instantly share code, notes, and snippets.

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

Evgeny Zislis kesor

🏠
Working from home
View GitHub Profile
require 'fog'
connection = Fog::Compute.new(
provider: 'AWS',
aws_access_key_id: 'AKIAIEXAMPLEEXAMPLE6',
aws_secret_access_key: 'example+example+example+example+example7',
region: 'us-east-1'
)
connection.servers.all.each do |server|
puts server.id
@kesor
kesor / Gemfile
Created March 19, 2013 00:32
Vagrant configuration to install two Ubuntu 12.04 servers, first server has a Chef Server installed, second server has a Chef Client installed, and the folder where these files are places is configured to be a Chef Workstation using admin.pem.
source "https://rubygems.org"
gem 'chef', '>= 11.0'
gem 'librarian'
gem 'vagrant', '= 1.0.6'
gem 'vagrant-hostmaster'
gem 'foodcritic'
@kesor
kesor / gist:5411806
Last active December 16, 2015 09:19
## using https://github.com/apsoto/monit/ cookbook
## this works
bind_cookbook_name = cookbook_name
monitrc 'redis' do
action :enable
reload :delayed
variables({ :pidfile => "/var/run/redis/6379/redis_6379.pid" })
template_cookbook bind_cookbook_name
template_source 'redis_monit.conf.erb'
AJS.toInit(function () {
AJS.$("[name=run_dynamic_publisher_id]").select2({width: "400px"});
$("[class^=atlassian-select2]").each(function (ei, ee) {
ee.className = ee.className.replace("atlassian-select2", "select2");
});
})
@kesor
kesor / gist:5549876
Last active December 17, 2015 04:19
Open3.popen3 cmd do |sin, sout, serr, wait_thr|
loop do
rs, _, _ = IO.select([sout,serr]) # no multi-assign in conditions
break if (sout.eof? and serr.eof?) or (sout.closed? and serr.closed?)
next if rs.empty?
rs.each do |readable_io|
log readable_io.gets # read a line from it
end
end
exit_status = wait_thr.value
@kesor
kesor / mysql_rotate_large_table.sql
Last active January 24, 2019 20:33
Rotate huge tables to old_tablename without affecting continued writes to these tables and keeping existing indexes and auto_increment counters.
DROP PROCEDURE IF EXISTS rotateAudit;
delimiter ;;
CREATE PROCEDURE rotateAudit(
pv_database VARCHAR(64),
pv_table VARCHAR(64)
)
BEGIN
SET @createDbStatement := CONCAT('CREATE DATABASE IF NOT EXISTS archive_',pv_database);
SET @createStatement := CONCAT('CREATE TABLE ',pv_database,'.new_',pv_table,' LIKE ',pv_database,'.',pv_table);
SET @insertStatement := CONCAT('INSERT INTO ',pv_database,'.new_',pv_table,' SELECT * FROM ',pv_database,'.',pv_table,' ORDER BY id DESC LIMIT 50000');
@kesor
kesor / graphite_magic
Last active December 18, 2015 09:19
Graphite deviation from average of last couple of weeks
target=diffSeries(
app.important.stuff,
averageSeries(
timeShift(app.important.stuff, "-7d"),
timeShift(app.important.stuff, "-14d"),
timeShift(app.important.stuff, "-21d")
)
)
@kesor
kesor / client.yaml
Last active December 19, 2015 00:09
# /etc/puppet/config/client.yaml
---
client: example.com
environment: vagrant
@kesor
kesor / varnish.txt
Last active December 19, 2015 12:19
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
if (req.request == "POST") {
return (pipe);
}
if (req.url ~ "^/(s/|favicon.ico|download/resources/|download/batch/|images/icons/)") {
@kesor
kesor / an upstart unicorn.conf
Last active February 9, 2022 09:20
Unicorn that receives USR2 signal on upstart's "stop unicorn", but also allows upstart to respawn it when for some reason it crashed on its own.
# unicorn
description "unicorn ruby app server"
start on (local-filesystems and net-device-up IFACE=lo and runlevel [2345])
stop on runlevel [!2345]
env WORKDIR=/data
env PIDFILE=/data/tmp/pids/unicorn.pid
env CFGFILE=/data/config/unicorn.rb