Skip to content

Instantly share code, notes, and snippets.

@droznyk
droznyk / ruby-project-stats.rb
Created March 9, 2023 13:08 — forked from louismullie/ruby-project-stats.rb
Count the number of files, lines of code and comments in a Ruby project.
o = 0 # Number of files
n = 0 # Number of lines of code
m = 0 # Number of lines of comments
files = Dir.glob('/path/to/dir/**/*.rb')
files.each do |f|
next if FileTest.directory?(f)
o += 1
i = 0
lines = []
@droznyk
droznyk / mysql-docker.sh
Created July 24, 2020 13:08 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@droznyk
droznyk / css-selectors.md
Created June 9, 2020 08:20 — forked from magicznyleszek/css-selectors.md
CSS Selectors Cheatsheet

CSS Selectors Cheatsheet

Element selectors

Element -- selects all h2 elements on the page

h2 {
    foo: bar;
@droznyk
droznyk / input.json
Created November 7, 2019 13:19
Example data from SWAPI
{
"name":"Millennium Falcon",
"passengers":"6",
"pilotConnection":{
"pilots":[
{
"name":"Chewbacca",
"species":{
"name":"Wookiee"
}
@droznyk
droznyk / meow.rb
Created November 7, 2019 12:28
Pattern matching - syntax error when using methods in pattern.
class Cat
def meow
"Meow!"
end
end
cat = Cat.new
case "Meow!"
in cat.meow
"Reached"
@droznyk
droznyk / syntax.rb
Last active May 4, 2020 07:14
Pattern matching syntax
case expression
in pattern [if | unless condition]
# here goes the code
in pattern [if | unless condition]
# here goes the code
else
# here goes the code
end