Skip to content

Instantly share code, notes, and snippets.

View NickKelly1's full-sized avatar

nickk NickKelly1

  • MyEtherWallet
  • Los Angeles, California
View GitHub Profile
@NickKelly1
NickKelly1 / ssh-here-document.sh
Created March 31, 2022 07:25 — forked from pietrorea/ssh-here-document.sh
SSH config here document
cat > /etc/ssh/sshd_config << "EOF"
Include /etc/ssh/sshd_config.d/*.conf
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
...
EOF
@NickKelly1
NickKelly1 / blacklist.md
Last active March 1, 2022 19:11
Pure ESM `npm` packages to avoid and their alternatives
@NickKelly1
NickKelly1 / gist:2800873ffc764c9803b1facd998a0712
Last active August 7, 2021 00:06
Benchmark: next.js recursiveCopy fs.stat vs fs.readdir.withFileTypes
/*
NodeJS version: 16.4.1
Note: benchmarks not run in separate processes - expect some early noise
45 files
size: 4.7M
---- 1
new: 4.3ms
old: 4.0ms
---- 2
@NickKelly1
NickKelly1 / jsdoc.md
Last active August 27, 2021 19:58
JSDoc examples

JSDoc

Examples

// reusable type definition

/**
 * @typedef {{
 *  title: string;
version: "3"
services:
example_gql_ts_accounts:
container_name: example_gql_ts_accounts
image: nick3141/example-gql-ts-accounts:latest
restart: unless-stopped
ports:
- 5000:5000
environment:
docker run \
--name example_gql_ts_accounts \
-p 5000:5000 \
-e PORT=5000 \
-e LOG_DIR=./storage/logs \
-e LOG_MAX_SIZE=20m \
-e LOG_ROTATION_MAX_AGE=7d \
-e RATE_LIMIT_WINDOW_MS=60000 \
-e RATE_LIMIT_MAX=100 \
--rm \
// Guard example from TypeGraphQL, using the @Authorized decorator
@Resolver()
class MyResolver {
// Since the logic is statically attached to the endpoint and inaccessable elsewhere in the
// application, we can't publish this authorisation to the client without duplicating the logic
// (i.e. const canDoThing = user.permissions.includes("ADMIN")...)
@Authorized("ADMIN")
@Query()
authedQuery(): string {
/**
* @ account/account.policy.ts
*
* AccountPolicy
*
* Handles authorisation for Accounts
*/
export class AccountPolicy {
constructor(
protected readonly ctx: BaseContext,
/**
* @ account/account.gql.node.ts
*
* AccountNode
*
* GrapQLObjectType for an Account
*/
// AccountNode Source is an AccountModel from our ORM
export type IAccountNodeSource = AccountModel;
query {
rootNode{
# paginated connection node
# must provide the root nodes source to the xToManyRelation's resolver
xToManyRelation{
pageInfo
childNodes{ ... }
}
}
}