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
require "benchmark/ips"
ARRAY = [*1..100]
def fast
index = 0
while index < ARRAY.size
ARRAY[index] + index
index += 1
end
@GalenkoEugene
GalenkoEugene / git branch config
Created November 23, 2019 19:40
Git branch command behaves like 'less'
git config --global pager.branch false
https://stackoverflow.com/questions/48341920/git-branch-command-behaves-like-less/48370253#48370253
@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 / 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 \
@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 / 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 / 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."
https://github.com/Microsoft/TypeScript/issues/2440