Skip to content

Instantly share code, notes, and snippets.

View DmitryBash's full-sized avatar

Batracov Dmitrii DmitryBash

  • Netherlands
View GitHub Profile
class C
def self.no_dot
puts "Self is #{self}"
end
self.no_dot
no_dot
end
#Не особо понимаю разницу между вызовом просто no_dot и self.no_dot

Setup

Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug.

gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]

Using PRY

@DmitryBash
DmitryBash / test_channel_spec.rb
Created October 15, 2018 07:37 — forked from tomekw/test_channel_spec.rb
Unit testing ActionCable channels with RSpec
# app/channels/hello_channel.rb
class HelloChannel < ActionCable::Channel::Base
def say_hello(data)
times_to_say_hello = data.fetch("times_to_say_hello")
hello = "Hello, #{current_profile.name}!"
times_to_say_hello.times do
ActionCable.server.broadcast(current_profile.id, hello)
end
end
http://merle-amber.blogspot.com/2008/09/mock.html
https://vasily.polovnyov.ru/posts/double-mock-stub.html
https://habr.com/post/169381/
http://rubyblog.pro/2017/10/rspec-difference-between-mocks-and-stubs
https://relishapp.com/rspec/rspec-mocks/docs/basics/partial-test-doubles
http://lazybios.com/2016/08/rspec-expectations-cheat-sheet/
https://vasily.polovnyov.ru/posts/double-mock-stub.html
https://vasily.polovnyov.ru/posts/describe-vs-context.html
https://relishapp.com/rspec/rspec-mocks/v/2-99/docs/method-stubs
https://stackoverflow.com/questions/39626805/passing-parameters-to-an-rspec-shared-example
https://chris.beams.io/posts/git-commit/
https://ncona.com/2011/07/how-to-delete-a-commit-in-git-local-and-remote/
http://christoph.ruegg.name/blog/git-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html
https://stackoverflow.com/questions/10153486/how-to-delete-the-last-n-commit-on-github-and-locally
https://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github
https://toster.ru/q/455554 - how to checkout git reset --hard
https://git-scm.com/book/ru/v1/Git-%D0%B8%D0%B7%D0%BD%D1%83%D1%82%D1%80%D0%B8-%D0%9E%D0%B1%D1%81%D0%BB%D1%83%D0%B6%D0%B8%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5-%D0%B8-%D0%B2%D0%BE%D1%81%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D0%B4%D0%B0%D0%BD%D0%BD%D1%8B%D1%85 - Обслуживание и восстановление данных
https://chrisk.io/undo-git-pull/
https://support.beanstalkapp.com/article/1004-how-do-i-undo-things-in-git#3
https://git-scm.com/docs/git-annotate
https://github.com/rubocop-hq/ruby-style-guide
https://redisgreen.net/blog/pubsub-howto/ - redis pubsub
https://www.brianstorti.com/understanding-ruby-idiom-map-with-symbol/
https://www.youtube.com/watch?v=gIEMKOI_Y-4&t=1s - ruby 24 trics and tips
https://stackoverflow.com/questions/14881125/what-does-to-proc-method-mean
http://maximomussini.com/posts/ruby-to_proc/
https://bparanj.gitbooks.io/ruby-basics/content/part2/binding.html
https://www.reddit.com/r/ruby/comments/981kjw/10_ruby_tricks_we_should_use_to_improve_the_code/
https://www.driftingruby.com/episodes/random-ruby-tips-and-tricks
http://www.virtuouscode.com/2013/12/25/exception-causes-in-ruby-2-1/
https://stackoverflow.com/questions/34424154/rails-validate-uniqueness-of-two-columns-together
https://matt.aimonetti.net/posts/2013/11/30/sharing-rails-sessions-with-non-ruby-apps/
https://codeburst.io/elixir-beside-rails-2b94414bcb03
https://www.google.com/search?q=rails+associations+tips&oq=rails+associations+tips&aqs=chrome..69i57j69i65j69i60j0l3.4166j0j7&sourceid=chrome&ie=UTF-8
https://blog.bigbinary.com/2013/07/01/preload-vs-eager-load-vs-joins-vs-includes.html
https://www.howtographql.com/graphql-ruby/0-introduction/
http://www.mitchcrowe.com/10-most-underused-activerecord-relation-methods/
https://github.com/leandromoreira/redlock-rb
https://medium.com/@devinburnette/be-prepared-7768d1a111e1
https://gist.github.com/rafaelsales/86ca62c45108abe7162a87813fea8e7e - what i dislike
@DmitryBash
DmitryBash / webpacker_rails.md
Created November 3, 2019 22:22 — forked from maxivak/webpacker_rails.md
Webpack, Yarn, Npm in Rails
@DmitryBash
DmitryBash / 01.1.lifecycle.rb
Created November 3, 2019 23:02 — forked from Aupajo/01.1.lifecycle.rb
Sockets in Ruby
require 'socket'
# 1. Create
# AF_INET means IPv4 (xxx.xxx.xxx.xxx)
# SOCK_STREAM means communicating with a stream (TCP)
#
# Can be simplified to symbols :INET and :STREAM, respectively
server = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger