Skip to content

Instantly share code, notes, and snippets.

View Luke-Rogerson's full-sized avatar

Luke Rogerson Luke-Rogerson

View GitHub Profile
/**
* @dev Taken from OpenZeppelin Contracts (access/Ownable.sol).
* Represents the project owner entity of a given project.
* Names have been changed, but otherwise the code is identical.
*/
abstract contract ProjectRole is Context {
address private _projectOwner;
event ProjectOwnershipTransferred(address indexed previousProjectOwner, address indexed newProjectOwner);
logger = use_logging()
logger.info('An informative log message', extra={'user_id': 'abc123', **function_args})
class LogLevel(Enum):
CRITICAL = CRITICAL
DEBUG = DEBUG
ERROR = ERROR
FATAL = FATAL
INFO = INFO
NOTSET = NOTSET
WARNING = WARNING
{
"version": "2.0.0",
"tasks": [
{
"label": "add_requirements",
"type": "shell",
"command": "poetry export -f requirements.txt --without-hashes > requirements.txt"
},
]
}
@Luke-Rogerson
Luke-Rogerson / launch.json
Last active July 26, 2021 20:47
An example setup for debugging Serverless Framework Lambda functions in VSCode
{
"configurations": [
{
"preLaunchTask": "add_requirements",
"type": "aws-sam",
"request": "direct-invoke",
"name": "whatever",
"invokeTarget": {
"target": "code",
"lambdaHandler": "path.to.your.handler.handler_name",
@Luke-Rogerson
Luke-Rogerson / quiz-answers.md
Last active September 27, 2020 13:55
Family quiz answers

Family quiz - September 2020

  1. Donald Duck bowtie is red
  2. Thomas Cromwell's wife was called Elizabeth
  3. “你好" means "hello" 👋 in Chinese
  4. "Yay" is printed
  5. Rowan Atkinson had a small part in Never Say Never Again
  6. Graham Atkinson with 107
  7. George Washington did (in a speech drafted by Alexander Hamilton)
  8. The Security Council of the United Nations only has five permanent members - China, France, Russia, the UK and the US. Germany is currently one of the ten additional, temporary members which hold their seats on a rotating basis by geographic region.
// prepended with "mock"
const mockNavigateToProfile = jest.fn()
jest.mock('@react-navigation/native', () => {
// ...the same
})
test('it should navigate to user profile on press', () => {
// ...the same
})
const navigateToProfile = jest.fn()
// notice we're using "doMock" here
jest.doMock('@react-navigation/native', () => {
// ...the same
})
test('it should navigate to user profile on press', () => {
// ...the same
})
const navigateToProfile = jest.fn()
jest.mock('@react-navigation/native', () => {
const module = jest.requireActual('@react-navigation/native')
return {
...module,
useNavigation: {
navigate: () => ({
navigate: navigateToProfile,
}),
@Luke-Rogerson
Luke-Rogerson / apollo-resolver-test-snippet.json
Last active August 12, 2020 16:22
This is a VSCode gist to generate an Apollo cache update resolver test for easy TDDing
"TypeScript Apollo Resolver Test": {
"prefix": "tart",
"body": [
"import { FetchResult } from 'apollo-link'",
"import { DataProxy } from 'apollo-cache'",
"import { createMockResolverArgs } from '@rg-dev/apollo/src/test-utils/resolvers.utils'",
"",
"afterEach(() => jest.clearAllMocks())",
"",
"test('it should ', () => {",