This file contains 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
// web/src/components/FatalErrorBoundary/FatalErrorBoundary.js | |
import { FatalErrorBoundary as FatalErrorBoundaryBase } from '@redwoodjs/web' | |
import * as Sentry from '@sentry/browser' | |
class FatalErrorBoundary extends FatalErrorBoundaryBase { | |
componentDidCatch(error, errorInfo) { | |
Sentry.withScope((scope) => { | |
scope.setExtras(errorInfo) | |
Sentry.captureException(error) | |
}) |
This file contains 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
{ | |
"Statement":[ | |
{ | |
"Effect":"Allow", | |
"Action":[ | |
"s3:ListAllMyBuckets" | |
], | |
"Resource":"arn:aws:s3:::*" | |
}, |
This file contains 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 * as React from 'react'; | |
const WeekendStatus = () => { | |
const dayOfWeek = new Date().getDay(); | |
const isWeekend = [0, 6].includes(dayOfWeek); | |
if (isWeekend) { | |
return <p>It's the weekend!</p>; | |
} | |
return <p>It is not the weekend :(</p>; | |
}; |
This file contains 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
const App = () => ( | |
<TimeProvider> | |
<h1>My App</h1> | |
<GetTime> | |
{({ currentTime }) => <WeekendStatus currentTime={currentTime} />} | |
</GetTime> | |
</TimeProvider> | |
); |
This file contains 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
// We need an impure function that will give us the current time. | |
// Notice that we return the ISO string version of the date. This is nice | |
// because it is not a mutable object like `Date` and it is also a | |
// human readable representation. | |
const defaultGetTime = () => new Date().toISOString(); | |
export default class TimeProvider extends React.PureComponent { | |
static defaultProps = { | |
interval: 500, | |
}; |
This file contains 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
export const withTime = WrappedComponent => props => ( | |
<GetTime> | |
{({ currentTime }) => ( | |
<WrappedComponent | |
// by passing currentTime first and ...props second, we allow | |
// parent components to override the currentTime | |
currentTime={currentTime} | |
{...props} | |
/> | |
)} |
This file contains 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 * as React from 'react'; | |
const WeekendStatus = ({ currentTime }) => { | |
// Because we take currentTime as a prop, we now no longer depend | |
// on the external system time in our render function. We are now | |
// a pure function | |
const dayOfWeek = new Date(currentTime).getDay(); | |
const isWeekend = [0, 6].includes(dayOfWeek); | |
if (isWeekend) { | |
return <p>It's the weekend!</p>; |
This file contains 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 django import template | |
register = template.Library() | |
leading_whitespace_re = re.compile(r'^\s+', flags=re.MULTILINE) | |
@register.tag(name='dedent') | |
def do_dedent(parser, token): |
This file contains 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 ComparableModel(object): | |
""" | |
Make models comparable based on the Meta.ordering. Usage: | |
>>> import datetime | |
>>> class MyModel(ComparableModel, models.Model): | |
>>> name = models.CharField(max_length=255) | |
>>> birthdate = models.DateField() | |
>>> class Meta: | |
>>> app_label = 'test' |
This file contains 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
# Example Usage | |
from .settings_s3 import * |
NewerOlder