Skip to content

Instantly share code, notes, and snippets.

View vadimstroganov's full-sized avatar

Vadim Stroganov vadimstroganov

  • Saint-Petersburg, Russia
View GitHub Profile
@vadimstroganov
vadimstroganov / rbenv-ruby-build.sh
Created July 19, 2018 13:05
Install rbenv and ruby-build
# install rbenv
git clone https://github.com/rbenv/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
# install ruby-build
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
# verify
@vadimstroganov
vadimstroganov / dry-transaction.rb
Last active May 16, 2021 02:00
Rails example for dry-transaction and dry-validation
# app/controllers/users_controller.rb
class UsersController < ApplicationController
def create
Operations::User::Create.new.call(params[:user]) do |m|
m.success do |user_response|
render json: user_response
end
m.failure do |responce|
render json: responce, status: :not_acceptable
@vadimstroganov
vadimstroganov / install-libsodium.sh
Created November 1, 2016 20:54 — forked from jonathanpmartins/install-libsodium.sh
Install Libsodium on Ubuntu 14.04.3 LTS Trusty
#!/bin/bash
sudo add-apt-repository ppa:chris-lea/libsodium;
sudo echo "deb http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list;
sudo echo "deb-src http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list;
sudo apt-get update && sudo apt-get install libsodium-dev;
@vadimstroganov
vadimstroganov / ecdh.rb
Created October 31, 2016 18:06 — forked from sabril/ecdh.rb
#openssl
require 'openssl'
require 'base64'
require "digest"
include OpenSSL
def aes256_encrypt(key, data)
key = Digest::SHA256.digest(key) if(key.kind_of?(String) && 32 != key.bytesize)
aes = OpenSSL::Cipher.new('AES-256-CBC')
aes.encrypt
class ClassName < ParentClassName
def index
end
def show
end
def new
end