Snippets Collections
% pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
version: 12.2.0.0.1.1604076827
class ChangeDefaultvalueForHideSeasonSelector < ActiveRecord::Migration 
  def change 
    change_column_default :plussites, :hide_season_selector, true 
  end
end
txt = "a,s(d,f(4,5)),g,h"
pattern = Regexp.new('((?:[^,(]+|(\((?>[^()]+|\g<-1>)*\)))+)')
puts txt.scan(pattern).map &:first




(                        # first capturing group
    (?:                  # open a non capturing group
        [^,(]+           # all characters except , and (
      |                  # or
        (                # open the second capturing group
           \(            # (
            (?>          # open an atomic group
                [^()]+   # all characters except parenthesis
              |          # OR
                \g<-1>   # the last capturing group (you can also write \g<2>)
            )*           # close the atomic group
            \)           # )
        )                # close the second capturing group
    )+                   # close the non-capturing group and repeat it
)                        # close the first capturing group
When you want an optional belongs_to:


1) Just don't add in the field's migration
#migration_file_name.rb
#PLEASE DO NOT DO
null: false 

2) In the model use
#PLEASE DO
belongs_to :community, optional: true
puts ShopifyAPI::Order.find(:all, :params => {:status => 'any', :limit => 250})
star

Sun Jan 03 2021 06:08:11 GMT+0000 (UTC) https://stackoverflow.com/questions/64942215/ld-library-not-found-for-lsystem-when-installing-homebrew-ruby-on-big-sur

#rb
star

Thu Aug 27 2020 16:52:41 GMT+0000 (UTC) https://stackoverflow.com/questions/42668391/change-the-default-value-for-table-column-with-migration

#rb
star

Fri Aug 21 2020 20:20:59 GMT+0000 (UTC) https://stackoverflow.com/questions/18424315/how-do-i-split-a-string-by-commas-except-inside-parenthesis-using-a-regular-exp

#rb
star

Thu Aug 20 2020 01:16:40 GMT+0000 (UTC) https://stackoverflow.com/questions/46053658/how-to-make-a-models-column-optional-in-rails5

#rb #rubyonrails
star

Thu Aug 13 2020 20:55:41 GMT+0000 (UTC) https://stackoverflow.com/questions/1514883/determine-if-a-value-exists-in-an-array-of-hashes

#rb
star

Mon Jun 22 2020 16:12:54 GMT+0000 (UTC) https://stackoverflow.com/questions/23824715/how-to-retrieve-orders-from-shopify-through-the-shopify-api-gem

#rb

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension