Skip to content

Instantly share code, notes, and snippets.

View GalenkoEugene's full-sized avatar
💭
🇺🇦

Yevhenii Halenko GalenkoEugene

💭
🇺🇦
View GitHub Profile
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@GalenkoEugene
GalenkoEugene / capybara cheat sheet
Last active September 13, 2017 12:49 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
git rebase -i HEAD~2 - squash 2 last commit

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@GalenkoEugene
GalenkoEugene / socket-cheatsheet.js
Created January 25, 2018 16:04 — forked from alexpchin/socket-cheatsheet.js
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
https://github.com/Microsoft/TypeScript/issues/2440
@GalenkoEugene
GalenkoEugene / rhtml2html.erb.rb
Last active April 3, 2018 07:14
converts all rhtml files to html.erb
# converts all rhtml files to html.erb
require 'fileutils'
files = `find app/views -name '*.rhtml'`
file_ary = files.split("\n")
file_ary.each do |file|
new_file = file.gsub('rhtml', 'html.erb')
FileUtils.mv file, new_file
end
puts "#{file_ary.length} files converted."
@GalenkoEugene
GalenkoEugene / convert_to_UTF-8.rb
Last active March 12, 2018 13:32
Rails Error: “\xE4” followed by “l” on UTF-8
Dir['*/**/*.js', '*/**/*.css'].each do |f|
File.write f, File.read(f).force_encoding('ISO-8859-1').encode('UTF-8')
end
@GalenkoEugene
GalenkoEugene / custom_logger.rb
Created March 22, 2018 14:33 — forked from kinopyo/custom_logger.rb
Custom logger file in Rails
# lib/custom_logger.rb
class CustomLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file
logfile.sync = true # automatically flushes data to file
CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere
@GalenkoEugene
GalenkoEugene / Dockerfile
Last active July 7, 2018 11:15
convert database from Mysql to Postgresql
FROM ubuntu:latest
MAINTAINER Evhenii Halenko 'Re4port@ukr.net'
RUN apt update -y \
&& apt install -y build-essential \
netcat \
curl \
wget \
tzdata \