Skip to content

Instantly share code, notes, and snippets.

View DmitryBash's full-sized avatar

Batracov Dmitrii DmitryBash

  • Netherlands
View GitHub Profile
@DmitryBash
DmitryBash / custom_reverse.rb
Last active December 18, 2023 14:05
reverse array
def reverse_array(arr)
return arr if arr.empty?
arr = arr.dup
start_index = 0
end_index = arr.length - 1
while start_index < end_index
arr[start_index], arr[end_index] = arr[end_index], arr[start_index]
@DmitryBash
DmitryBash / test.rb
Last active September 14, 2021 13:54
test
def query(params)
# this magic method prepares sql and gets correct data from DB
# NO CHANGES HERE
puts "Params = #{params}"
[
{name: "John", surname: "Doe", age: 33},
{name: "John", surname: "Doe", age: 34},
{name: "John", surname: "Doe", age: 35}
]
end
@DmitryBash
DmitryBash / readme.md
Created April 30, 2020 07:18 — forked from maxivak/readme.md
Send email to multiple recipients in Rails with ActionMailer

Send email to multiple recipients

Send multiple emails to different recipients.

Mailer class

# app/mailers/notify_mailer.rb

class NotifyMailer < ApplicationMailer
@DmitryBash
DmitryBash / js-functions-syntax.js
Created April 5, 2020 16:57
redux-examples-002-dispatch-mapdispatchtoprops
class Profile extends React.Component {
render(props) {
return <div>{props}</div>
}
}
// Dumb component
function Profile(props) {
return <div>{props}</div>
@DmitryBash
DmitryBash / docker-pry-rails.md
Created March 26, 2020 14:04 — forked from briankung/docker-pry-rails.md
Using pry-rails with Docker
import React from 'react'
// Example 1: translation
const TranslationContext = {
// most likely, from Provider or any other top-level component
locale: 'en',
strings: {
en: {
'user.my_account': 'My account'
@DmitryBash
DmitryBash / _README.md
Created March 24, 2020 14:06 — forked from shime/_README.md
comparing dates and times in RSpec

What is this?

How do you compare date/times in RSpec?

If you do this

expect(Time.now.to_i).to eq Time.new(2014, 4, 2).to_i
@DmitryBash
DmitryBash / kubernetes_commands.md
Created March 19, 2020 16:54 — forked from edsiper/kubernetes_commands.md
Kubernetes Useful Commands
@DmitryBash
DmitryBash / multiple_ssh_setting.md
Created March 19, 2020 16:08 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@DmitryBash
DmitryBash / rails-5-6-ubuntu-mina-puma-nginx.md
Created March 18, 2020 12:45 — forked from wafiq/rails-5-6-ubuntu-mina-puma-nginx.md
How to deploy Rails 5/6 in Ubuntu VM using Mina deployment with Puma webserver and Nginx

Rails 5 and 6 Deployment with Ubuntu, Mina, Puma and Nginx

Based on this tutorial but simplified and inlined. Particularly removed any Rails and 3rd party services part, assumed you just need deployment to any Ubuntu machine.

Prerequisite

  1. A functional Rails app
  2. Hosted Git repository (Github, Bitbucket, Gitlab)
  3. Cloud hosting account (Digital Ocean, Vultr, Linode, Lightsail)
  4. Local SSH account