Skip to content

Instantly share code, notes, and snippets.

@marshallmick007
Last active September 23, 2016 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshallmick007/a03b3f32278d104e01042ea780c809bf to your computer and use it in GitHub Desktop.
Save marshallmick007/a03b3f32278d104e01042ea780c809bf to your computer and use it in GitHub Desktop.

Merging two hashes

defaults = { :test => 1, :original => 'thing' }
overrides = { test: '42', :some_new_thing => 'cats' }
defaults.merge(overrides)
#{
#              :test => "42",
#          :original => "thing",
#    :some_new_thing => "cats"
#}

Testing if a string is a URI (specifically HTTP)

def is_valid_uri?(url)
  url =~ /\A#{URI::regexp(['http', 'https'])}\z/                                     
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment