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
module Kernel | |
def require_relative_with_tco file | |
absolute_path = File.absolute_path file, __dir__ | |
realpath = File.realpath "#{absolute_path.chomp '.rb'}.rb" | |
if $LOADED_FEATURES.include? realpath | |
false | |
else | |
RubyVM::InstructionSequence.compile_file( | |
realpath, |
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
#First install the webp converter by this | |
sudo apt-get install webp | |
#go inside the directory where all images are there | |
#make sure all images are in RGB color mode, otherwise you will get error for CMYK images. | |
#Convert all images to RGB by this command (you should install ImageMagik to do that) | |
for f in *.jpg; do convert -colorspace RGB "$f" "${f}"; done | |
#finally convert all images to Webp format |
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
# abc=a^3+b^3+c^3 | |
i = 0 | |
max = 999 | |
while i <=999 | |
puts i.to_s.rjust(3,'0') if i == ((i /100) ** 3) + ((i % 100 / 10) ** 3) + ((i % 10) ** 3) | |
i +=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
def print_out_specific_level(level) | |
traverse_specific_level(root_node, 1, level) | |
end | |
def traverse_specific_level(node, current_level, desired_level) | |
if (current_level == desired_level) | |
puts node.val | |
return | |
end |