Skip to content

Instantly share code, notes, and snippets.

View DesignByOnyx's full-sized avatar

Ryan Wheale DesignByOnyx

View GitHub Profile

Keybase proof

I hereby claim:

  • I am DesignByOnyx on github.
  • I am ryanwheale (https://keybase.io/ryanwheale) on keybase.
  • I have a public key whose fingerprint is 0DAA EB7B A5F5 F7AB 35F4 7593 818E 802D A122 192F

To claim this, I am signing this object:

@DesignByOnyx
DesignByOnyx / github-auto-link-yaml-refs-bookmarklet.js
Last active September 10, 2019 01:16
Bookmarklet to automatically turn YAML $refs into hyperlinks.
{
"title": "My first blog post",
"body": "...",
"tags": [
{ "text": "sequelize" },
{ "text": "feathersjs" },
{ "text": "many-to-many" }
]
}
const { tags, ...blogPost } = {
"title": "My first blog post",
"body": "...",
"tags": [
{ "text": "sequelize" },
{ "text": "feathersjs" },
{ "text": "many-to-many" }
]
};
const { tags, ...blogPost } = {
"title": "My second blog post",
"body": "...",
"tags": [
{ "id": 1, "text": "sequelize" }, // the existing tag has an "id"
{ "text": "database" } // the new tag does not have an "id"
]
};
const newPost = db.create('blog_posts', blogPost);
const { tags, ...blogPost } = {
"id": 1, // Notice the blog post has an "id" since we are updating an existing post
"title": "My first blog post",
"body": "...",
"tags": [
{ "id": 1, "text": "sequelize" }, // the existing tag has an "id"
{ "text": "postgres" } // the new tag does not have an "id"
]
};
@DesignByOnyx
DesignByOnyx / bootstrap-env-vars-test.ts
Last active January 16, 2024 02:15
Helper for testing different environment variables for individual tests
const bootstrapEnvVarsTests = <ModuleType>(modulePath: string) => {
const OLD_ENV = process.env;
beforeEach(() => {
// this allows us to reassign env vars for individual tests
jest.resetModules();
process.env = { ...OLD_ENV };
});
afterAll(() => {
process.env = OLD_ENV;