This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Generic object to dict converter. Recursively convert. | |
Useful for testing and asserting objects with expectation. | |
''' | |
def todict(obj, classkey=None): | |
if isinstance(obj, dict): | |
data = {} | |
for (k, v) in obj.items(): | |
data[k] = todict(v, classkey) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Prod Headless-Typescript | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build-test-job: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Dev Headless-Typescript | |
on: | |
push: | |
branches: [dev] | |
pull_request: | |
branches: [dev] | |
jobs: | |
build-test-job: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from typing import Dict, Callable, Optional | |
def to_camel_case(snake_case_str: str) -> str: | |
""" | |
Transforms snake_case to camelCase | |
""" | |
components = snake_case_str.split('_') | |
titled_components = ''.join(x.title() for x in components[1:]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is possible with Typescript 2.8+. You can declare an Unpacked<T> type as follows: | |
type Unpacked<T> = T extends (infer U)[] ? U : T; | |
type InnerCacheType = Unpacked<CacheType>; // Event | User | |
// This is a condensed definition of the Unpacked type given in the documentation. | |
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html | |
type Unpacked<T> = T extends Array<infer U> ? U : T extends ReadonlyArray<infer U> ? U : T; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{React.cloneElement(children as React.ReactElement<any>, {toggleOpenSidebar})} | |
{React.Children.map(children, (child => React.cloneElement(child as React.ReactElement<any>, {toggleOpenSidebar})))} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check version | |
node -v || node --version | |
// list installed versions of node (via nvm) | |
nvm ls | |
// install specific version of node | |
nvm install 6.9.2 | |
// set default version of node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Member(DjangoObjectType): | |
class Meta: | |
model = models.Member | |
filter_fields = [] | |
interfaces = (graphene.Node, ) | |
contacts = graphene.ConnectionField('api.graphql.Contact') | |
def resolve_contacts(instance, info): | |
info.context.root = instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You can access the URL kwargs with self.kwargs, so for example: | |
def get_object(self, queryset=None): | |
return Employee.objects.get( | |
user=self.request.user, | |
pk=self.kwargs['id'] | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Browserslist: caniuse-lite is outdated. Please run: | |
npx browserslist@latest --update-db | |
Why you should do it regularly: | |
https://github.com/browserslist/browserslist#browsers-data-updating |
NewerOlder