Skip to content

Instantly share code, notes, and snippets.

View mcdonnez's full-sized avatar

Zach McDonnell mcdonnez

  • Qualtrics
  • Springville, Utah
View GitHub Profile
@mcdonnez
mcdonnez / variable_declaration.py
Created October 14, 2021 14:48
Typing isn't required in python
foo = None
@mcdonnez
mcdonnez / json_encoder.py
Created October 14, 2021 14:55
Custom JSON Encoder to convert snake_case properties to camelCase json
"""Custom JSON Encoder to convert snake_case properties to camelCase json"""
import json
def to_camel_case(snake_str):
"""converts snake_case to camelCase"""
components = snake_str.split('_')
# We capitalize the first letter of each component except the first one
# with the 'title' method and join them together.
return components[0] + ''.join(x.title() for x in components[1:])
@dataclass
class FooBar:
  id: str
  description: str
score: float
my_var: FooBar = FooBar()