Skip to content

Instantly share code, notes, and snippets.

View GalenkoEugene's full-sized avatar
💭
🇺🇦

Yevhenii Halenko GalenkoEugene

💭
🇺🇦
View GitHub Profile
@GalenkoEugene
GalenkoEugene / AG tutorial.md
Created February 22, 2023 09:22 — forked from sonulohani/AG tutorial.md
AG tool cheatsheet
  • Find files containing "foo", and print the line matches in context: ag foo
  • Find files containing "foo" in a specific directory: ag foo path/to/directory
  • Find files containing "foo", but only list the filenames: ag -l foo
  • Find files containing "FOO" case-insensitively, and print only the match, rather than the whole line: ag -i -o FOO
  • Find "foo" in files with a name matching "bar": ag foo -G bar
@GalenkoEugene
GalenkoEugene / gist:0fa4e68b873f01348310e1681a456cfc
Created August 2, 2018 10:43 — forked from bkimble/gist:1365005
List local memcached keys using Ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []

Modifying an Existing Docker Image

To install a custom package or modify an existing docker image we need to

  1. run a docker a container from the image we wish to modify
  2. modify the docker container
  3. commit the changes to the container as a docker image
  4. test changes made to image

1.) Running a docker container from an image

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

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 / 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')
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