Skip to content

Instantly share code, notes, and snippets.

View Rojo's full-sized avatar
🏠
Working from home

Rojo

🏠
Working from home
  • México
View GitHub Profile
@Rojo
Rojo / require_relative_with_tco.rb
Created June 11, 2018 22:56 — forked from havenwood/require_relative_with_tco.rb
A #require_relative_with_tco that's like #require_relative but with tail call optimization
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,
@Rojo
Rojo / convert
Last active June 7, 2018 21:11 — forked from ahadyekta/convert
Bash: Convertir un grupo de archivos JPG a WEBP
#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
@Rojo
Rojo / suma_cubos.rb
Last active June 6, 2018 03:48 — forked from edymerchk/suma_cubos.rb
Para los números del 0 al 999, realizar la suma de los cubos de los digitos que los componen.
# 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
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