Skip to content

Instantly share code, notes, and snippets.


So Awesome Man awesome

View GitHub Profile
View guide: use puma-dev as
View ruby-require-a-local-file-or-gem-in-irb.rb
# via
# If you want to require a local file or gem in irb, I like this method:
# irb -I lib -r usps_countries
# This allows you to then require the module in your new irb instance:
# require 'usps_countries'
# Options used:
View gist:b592620313d4ff8712800b40d1e1511b
Originall From: Posted 2015-05-29
This is the complete list that’s outputted by ffmpeg when running ffmpeg -h full.
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Getting help:
-h — print basic options
-h long — print more options
-h full — print all options (including all format and codec specific options, very long)
awesome / ruby-regexp-uuid-and-dash-optional.rb
Last active Sep 5, 2022
UUID pure regexp and dash/hyphen is optional; return only full uuid matched
View ruby-regexp-uuid-and-dash-optional.rb
# refactor by soawesomeman
# further refactor by soawesomeman
# see:
awesome / ruby-hash-with-or-without-rockets-to-javascript-object-notation-aka-json-style-howto-by-soawesomeman.rb
Created Jun 28, 2022
View ruby-hash-with-or-without-rockets-to-javascript-object-notation-aka-json-style-howto-by-soawesomeman.rb
# ruby-hash-with-or-without-rockets-to-javascript-object-notation-aka-json-style.rb
# - context:
# - regex by SoAwesomeMane:
# - regex research:
# - more regex research: "\k Named backreference"
# - json schema from
# - 🍻🍻🍻
hash = {"$schema"=>"",
awesome / format-ticket-title-to-git-branch-name.rb
Created Jun 21, 2022
format ticket title to git branch name
View format-ticket-title-to-git-branch-name.rb
str = "ZZZ://ZZZZZZ (ZZZZ allocation - slider does not automatically reflect the entered Stop value and requires a click outside o
f the Stop input field)"
str.downcase.gsub(/\W/, '-').squeeze('-')[0..45].chomp('-')
# => "zzz-zzzzzz-zzzz-allocation-slider-does-not-aut"
awesome / pad-an-array-to-be-a-certain-size.rb
Created Dec 17, 2021
Pad An Array To Be A Certain Size in Ruby
View pad-an-array-to-be-a-certain-size.rb
def rpad(item, padding, num)
Array(item).fill padding, Array(item).size, num
awesome / ruby-url-to-hash-and-query-to-hash.rb
Created Dec 9, 2021
Ruby: URL-to-Hash & Query-to-Hash
View ruby-url-to-hash-and-query-to-hash.rb
RX_URL ='^((?<protocol>https?):\/\/)?(?<host>[^\/]+)(\/(?<path>[^\?#]+))?(\?(?<query>[^#]+))?(#(?<fragment>.*))?', 'i')
# @see
# @param url_str [String] URL string with or without `https://`, `http://`
# @return [Hash] hash with keys: `:protocol, :host, :path, :query, :fragment`
def url_to_hash(url_str)
m = url_str.match(RX_URL)
awesome / ruby-securerandom-fake-string-of-alphanumeric-characters-always-lead-with-alphabetic-characters.rb
Created Sep 14, 2021
Ruby SecureRandom fake string of alphanumeric characters; always lead with alphabetic characters.
View ruby-securerandom-fake-string-of-alphanumeric-characters-always-lead-with-alphabetic-characters.rb
# "generate a string with 0-9a-z (36 characters) that is ALWAYS 12 characters long. Change 12 to whatever length you want."
# -- Gerry Shaw via
# min length is 6
def fake_code(length = 12)
# always lead with four chars
str = SecureRandom.hex.gsub(/\d/, "")[0..3]
# followed by chars or int
awesome / ERB-h_html--j_json--t_textile--u_url.rb
Created Dec 4, 2020
2020 ERB escape and text-transformation
View ERB-h_html--j_json--t_textile--u_url.rb
# Using Text Transformation Methods
# ERB provides optional methods for transforming text.
# To use these features your code must include the module ERB::Util.
# via "An Introduction to ERB templating" (July 01, 2016)
# ERB transformation has changed since 2016: "j" not defined as alias but still executes without error, albiet weird rendering