Converting nested hash keys from CamelCase to snake_case in Ruby

If you use Rails: Example with hash: camelCase to snake_case: hash = { camelCase: ‘value1’, changeMe: ‘value2’ } hash.transform_keys { |key| key.to_s.underscore } # => { “camel_case” => “value1”, “change_me” => “value2” } source: http://apidock.com/rails/v4.0.2/Hash/transform_keys For nested attributes use deep_transform_keys instead of transform_keys, example: hash = { camelCase: ‘value1’, changeMe: { hereToo: { andMe: ‘thanks’ … Read more

Naming convention for upper case abbreviations [closed]

There is no one correct answer. This wiki extract is helpful: Programming identifiers often need to contain acronyms and initialisms which are already in upper case, such as “old HTML file”. By analogy with the title case rules, the natural camel case rendering would have the abbreviation all in upper case, namely “oldHTMLFile”. However, this … Read more

What is the naming convention in Python for variables and functions?

See Python PEP 8: Function and Variable Names: Function names should be lowercase, with words separated by underscores as necessary to improve readability. Variable names follow the same convention as function names. mixedCase is allowed only in contexts where that’s already the prevailing style (e.g. threading.py), to retain backwards compatibility.

Can I use camelCase in CSS class names

Technically yes, but it’s risky because while CSS syntax is mostly case-insensitive, in some browsers under certain conditions, class names are treated as case-sensitive, as the spec does not specify how browsers should handle case when matching CSS rules to HTML class names. From the spec, section 4.1.3: All CSS syntax is case-insensitive within the … Read more

Regex for PascalCased words (aka camelCased with leading uppercase letter)

([A-Z][a-z0-9]+)+ Assuming English. Use appropriate character classes if you want it internationalizable. This will match words such as “This”. If you want to only match words with at least two capitals, just use ([A-Z][a-z0-9]+){2,} UPDATE: As I mentioned in a comment, a better version is: [A-Z]([A-Z0-9]*[a-z][a-z0-9]*[A-Z]|[a-z0-9]*[A-Z][A-Z0-9]*[a-z])[A-Za-z0-9]* It matches strings that start with an uppercase letter, … Read more

Disable check of camel case rule in eslint

To disable the rule for a file add next line at the begging of a file: for JavaScript files: /* eslint-disable camelcase */ for TypeScript with enabled @typescript-eslint plugin: /* eslint-disable @typescript-eslint/camelcase */ To disable the rule for all files in a project add next line to the eslint config file: for JavaScript files: rules: … Read more

How to do CamelCase split in python

As @AplusKminus has explained, re.split() never splits on an empty pattern match. Therefore, instead of splitting, you should try finding the components you are interested in. Here is a solution using re.finditer() that emulates splitting: def camel_case_split(identifier): matches = finditer(‘.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)’, identifier) return [m.group(0) for m in matches]

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)