Skip to content

Instantly share code, notes, and snippets.

View DesignByOnyx's full-sized avatar

Ryan Wheale DesignByOnyx

View GitHub Profile
{
"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 / README.md
Last active December 26, 2021 02:11
A script for setting up a project to use semantic-ui-less

This script was inspired by this blog post - however I found the technique to be a little insufficient. Many thanks to Artem Butusov as I would not have been able to do this without his blog post.

This script is intended to be used with semantic-ui-react projects. If you are just using semantic-ui, then you may need to do some other troubleshooting... I don't know as I haven't tested. From what I can tell everything should work just fine.

Before we get started

This process is completely different from the one described in the blog post above. This script is intended to do everything for you - no manual copying or updating code is required. If you have already followed

@DesignByOnyx
DesignByOnyx / JS Comments REGEX - Failing Cases.md
Last active September 21, 2022 03:31
JS Comments REGEX - Failing Cases

This shows use cases where a simple regex like the one on StackOverflow cannot be relied upon for 100% accuracy in detecting comments in code.

Case 1 - comment-like characters within a string:

var foo = "There's no way to tell that this /* is not the beginning of a comment";
var bar = "There's no way to tell that this */ is not the end of a comment";
var baz = "There's no way to tell that this // is not a single line comment";
var buz = "Matters get much worse when there are escaped \" quotes /* inside the string. Definitely need a parser.";
var fiz = `And there is
@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;