Skip to content

Instantly share code, notes, and snippets.

View mthomps's full-sized avatar

Michael Thompson mthomps

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mthomps on github.
  • I am mthomps (https://keybase.io/mthomps) on keybase.
  • I have a public key ASAkGMEXUam-oe6qgbgQMMAkSqfdihGXznzf0Wwz-_JqWAo

To claim this, I am signing this object:

@mthomps
mthomps / flatten.rb
Created July 6, 2018 18:12
ruby flatten
def flatten(array)
result = []
array.each do |item|
if item.is_a? Integer
result << item
else
result.concat(flatten(item))
end
end
@mthomps
mthomps / gist:da53646465dac6971aec75c9def75191
Last active October 31, 2018 05:13
sublime text settings
{
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 35,
"auto_match_enabled": false,
"color_scheme": "Packages/Boxy Theme/schemes/Boxy Solarized Light.tmTheme",
"drag_text": false,
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
"*.pyc",
@mthomps
mthomps / add_param_to_url
Last active August 29, 2015 14:15
Ruby URLHelper to add a param to a url string
def add_param_to_url(url, param_key, param_val)
query = URI.parse(url).query
if query.present?
params = CGI::parse(query)
if params.present? && params[param_key].exclude?(param_val)
return "#{url}&#{param_key}=#{param_val}"
end
else
return "#{url}?#{param_key}=#{param_val}"
end