Skip to content

Instantly share code, notes, and snippets.

View EvGe22's full-sized avatar
🤔

Illia Strelnykov EvGe22

🤔
View GitHub Profile
@innat
innat / Path-Analysis-Neo4j-Cypher.md
Last active July 6, 2022 01:38
Path Analytics with CYPHER.

Viewing the graph

match (n:MyNode)-[r]->(m)

return n, r, m

Finding paths between specific nodes:*

@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_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

Network

We need a global docker network in order to communicate between docker-compose setups on different hosts

Step 1: Install and run Consul (as a key-value storage for docker)

https://www.consul.io/intro/getting-started/install.html

Step 2: Edit docker configuration (on each docker host)

@bbl
bbl / gotchas.md
Last active November 14, 2017 15:16
List of some weirdness and gotchas

Ruby

  1. Outside ENV strings are frozen:

example.rb:

ENV['foo'].strip!

Run:

How to run Chef-Solo programmatically:

require 'chef'
require 'chef/application/solo'

Chef::Config[:solo_legacy_mode] = true
Chef::Config[:cookbook_path] = [File.join(File.absolute_path(File.dirname(__FILE__)), 'cookbooks')]

chef_client = Chef::Application::Solo.new

Actually, it's a guide to setup docker macvlan network and it can be used to attach static ip to container on public/local network.

  1. Create docker public network:
docker network create -d macvlan --subnet=$SUBNET --gateway=$GATEWAY_IP -o parent=eth0 public

Where:
$SUBNET - your public network subnet
$GATEWAY_IP - your public network gateway

@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.
@bbl
bbl / AWS_SWAP.md
Last active November 14, 2017 15:16
Create and use swap on aws instance (or any other ubuntu machine)

Platform: Ubuntu 16.04

  1. It is common practice to create swap that equals to your RAM. So firstly, you should find out your RAM:
free -m

Which outputs like:

 total used free shared buff/cache available
  1. Add docker repo
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  1. Update