Skip to content

Instantly share code, notes, and snippets.

View dmytrotkk's full-sized avatar
🐵

Dmytro dmytrotkk

🐵
View GitHub Profile
@dmytrotkk
dmytrotkk / RunAProxyOnAmazonEC2VPC.md
Created August 28, 2017 20:15 — forked from webinista/RunAProxyOnAmazonEC2VPC.md
Create a proxy server on an Amazon EC2 (VPC) instance

This will create a proxy server in whatever your availability zone your VPC is in. For me, that's us-east-1b. For you, that may be something different. Steps 10+ should more or less work regardless of your provider since those steps cover the setup and configuration of TinyProxy.

  1. Click the Launch Instance button.
  2. Choose Ubuntu Server 14.04 LTS (HVM), SSD Volume Type. This isn't strictly necessary. If you choose another OS, check its documentation for how to install new packages.
  3. On the Choose an Instance Type screen, select t2.micro. It's Free Tier eligible.
  4. Click the Next: ... buttons until you reach the Configure Security Group screen.
    • You may wish to reduce the amount of storage on the Add Storage screen. This is optional.
    • You may wish to add a tag on the Tag Instance screen. This is also optional.
  5. On the Configure Security Group screen:
  • Select Create a new security group.
@dmytrotkk
dmytrotkk / rails_error_handling.md
Created November 8, 2017 14:42
Handling errors in Rails with ActiveSupport

Handling errors in Rails with ActiveSupport

Rails provide a clean way to rescue exceptions in a controller with a defined method.

Let's suppose that you have a class with method create that could raise ActiveRecord::RecordInvalid exception:

class ExampleController < ApplicationController

    def create
@dmytrotkk
dmytrotkk / rails_lib_services.md
Created November 14, 2017 13:07
Rails app: Organizing `lib` directory with static services

Organizing lib directory with static services

base_service.rb
    module Core end

    module Core::BaseService
 extend self
@dmytrotkk
dmytrotkk / rails_permissions.md
Created November 17, 2017 13:44
Checking permissions in Rails

Checking permissions in Rails

What we will use:

Let's just start with an example

Let's suppose that you have a method do_something, which could be preformed only by user who's matching permissions view_payment_info, if options[:some_key] isn't

@dmytrotkk
dmytrotkk / convoy_install.sh
Created October 8, 2019 09:59
Convoy install
wget https://github.com/rancher/convoy/releases/download/v0.5.2/convoy.tar.gz
tar xvzf convoy.tar.gz
sudo cp convoy/convoy convoy/convoy-pdata_tools /usr/local/bin/
sudo mkdir -p /etc/docker/plugins/
sudo bash -c 'echo "unix:///var/run/convoy/convoy.sock" > /etc/docker/plugins/convoy.spec'
@dmytrotkk
dmytrotkk / install_dm_helper.sh
Created October 18, 2019 10:02
Limit Docker volume size tutorial snippet
wget https://raw.githubusercontent.com/rancher/convoy/master/tools/dm_dev_partition.sh
bash dm_dev_partition.sh --write-to-disk $DISK_MOUNTPOINT
@dmytrotkk
dmytrotkk / run_convoy.sh
Created October 18, 2019 10:30
Limit Docker volume size tutorial snippet
convoy daemon --drivers devicemapper --driver-opts dm.datadev=$DISK_MOUNTPOINT\1 --driver-opts dm.metadatadev=$DISK_MOUNTPOINT\2 &
@dmytrotkk
dmytrotkk / convoy.service
Created October 18, 2019 10:34
Limit Docker volume size tutorial snippet
[Unit]
Description=Convoy volume management service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=5
ExecStart=convoy daemon --drivers devicemapper --driver-opts dm.datadev=$DISK_MOUNTPOINT\1 --driver-opts dm.metadatadev=$DISK_MOUNTPOINT\2
@dmytrotkk
dmytrotkk / docker_volume_create.sh
Created October 18, 2019 10:37
Limit Docker volume size tutorial snippet
docker volume create --driver convoy --opt size=100m test
@dmytrotkk
dmytrotkk / convoy_full_installation.sh
Last active January 9, 2020 21:16
Limit Docker volume size tutorial
# install convoy
wget https://github.com/rancher/convoy/releases/download/v0.5.2/convoy.tar.gz
tar xvzf convoy.tar.gz
sudo cp convoy/convoy convoy/convoy-pdata_tools /usr/local/bin/
sudo mkdir -p /etc/docker/plugins/
sudo bash -c 'echo "unix:///var/run/convoy/convoy.sock" > /etc/docker/plugins/convoy.spec'
# download and execute preparation script