Skip to content

Instantly share code, notes, and snippets.

View crmaxx's full-sized avatar

Maxim Zhukov crmaxx

  • Russia, Vladimir
View GitHub Profile
@crmaxx
crmaxx / update-hosts
Created October 4, 2023 10:27 — forked from jarlef/update-hosts
Shell script to update hosts file
#! /bin/sh
# @author: Jarle Friestad
# Based on script by Claus Witt (http://clauswitt.com/319.html)
# Adding or Removing Items to hosts file
# Use -h flag for help
DEFAULT_IP=127.0.0.1
IP=${3:-$DEFAULT_IP}
@crmaxx
crmaxx / deploy.rb
Created September 9, 2021 13:35 — forked from ayamomiji/deploy.rb
capistrano 3: precompile assets on local machine then upload
namespace :deploy do
namespace :assets do
Rake::Task['deploy:assets:precompile'].clear_actions
desc "Precompile assets on local machine and upload them to the server."
task :precompile do
run_locally do
execute 'RAILS_ENV=production bundle exec rake assets:precompile'
end
@crmaxx
crmaxx / puma.monitrc
Created March 15, 2019 10:05 — forked from sudara/puma.monitrc
Example config needed to use monit with puma, monitoring workers for mem.
# this monit config goes in /etc/monit/conf.d
check process puma_master
with pidfile /data/myapp/current/tmp/puma.pid
start program = "/etc/monit/scripts/puma start"
stop program = "/etc/monit/scripts/puma stop"
group myapp
check process puma_worker_0
with pidfile /data/myapp/current/tmp/puma_worker_0.pid
@crmaxx
crmaxx / README.md
Last active March 6, 2019 12:12 — forked from wvengen/README.md
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

@crmaxx
crmaxx / proc_composition-2.rb
Created January 25, 2019 08:40 — forked from dbourguignon/proc_composition-2.rb
Proc composition in ruby 2.6
require "bigdecimal"
# List of our individual pricing rules
TAX = ->(val) { val + val*0.05 }
FEE = ->(val) { val + 1 }
PREMIUM = ->(val) { val + 10 }
DISCOUNT = ->(val) { val * 0.90 }
ROUND_TO_CENT = ->(val) { val.round(2) }
# One presenter
PRESENT = ->(val) { val.to_f }
@crmaxx
crmaxx / postgres-brew.md
Created December 9, 2018 17:49 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@crmaxx
crmaxx / postgres_queries_and_commands.sql
Created September 25, 2018 10:49 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@crmaxx
crmaxx / p4merge install
Last active September 17, 2018 09:55 — forked from AaronGhent/p4merge install
Installs p4merge on a linux based machine
# p4merge for 64 bit
wget https://cdist2.perforce.com/perforce/r18.2/bin.linux26x86_64/p4v.tgz
tar zxvf p4v.tgz
sudo cp -r p4v-* /usr/local/p4v/
sudo ln -s /usr/local/p4v/bin/p4merge /usr/local/bin/p4merge
@crmaxx
crmaxx / test_mail_purge.rb
Created July 20, 2018 09:08 — forked from adamsanderson/test_mail_purge.rb
An example of using MiniTest::Mock
require 'minitest/mock'
require 'minitest/unit'
require 'date'
MiniTest::Unit.autorun
class TestMailPurge < MiniTest::Unit::TestCase
class MailPurge
def initialize(imap)
@imap = imap
@crmaxx
crmaxx / install_docker.sh
Created July 19, 2018 15:38 — forked from dpp/install_docker.sh
A script to install Docker on a minimal Ubuntu 16.04 machine
#!/bin/bash
apt-get update
apt-get install -y apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo ubuntu-xenial main' > /etc/apt/sources.list.d/docker.list
apt-get update