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
@ahadyekta
ahadyekta / convert
Created January 27, 2018 09:51
Batch convert JPG to WebP in Ubuntu
#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
@havenwood
havenwood / require_relative_with_tco.rb
Last active September 14, 2021 04:22
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,
@dhoelzgen
dhoelzgen / base_controller.rb
Last active October 7, 2021 16:19
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = '[email protected]'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }
@chetan
chetan / yardoc_cheatsheet.md
Last active April 13, 2025 14:08
YARD cheatsheet