- 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark/ips" | |
ARRAY = [*1..100] | |
def fast | |
index = 0 | |
while index < ARRAY.size | |
ARRAY[index] + index | |
index += 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global pager.branch false | |
https://stackoverflow.com/questions/48341920/git-branch-command-behaves-like-less/48370253#48370253 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 = [] |
To install a custom package or modify an existing docker image we need to
- run a docker a container from the image we wish to modify
- modify the docker container
- commit the changes to the container as a docker image
- test changes made to image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
MAINTAINER Evhenii Halenko 'Re4port@ukr.net' | |
RUN apt update -y \ | |
&& apt install -y build-essential \ | |
netcat \ | |
curl \ | |
wget \ | |
tzdata \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir['*/**/*.js', '*/**/*.css'].each do |f| | |
File.write f, File.read(f).force_encoding('ISO-8859-1').encode('UTF-8') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/Microsoft/TypeScript/issues/2440 |
NewerOlder