Skip to content

Instantly share code, notes, and snippets.

View DesignByOnyx's full-sized avatar

Ryan Wheale DesignByOnyx

View GitHub Profile
@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

const Sequelize = require('sequelize');
const sequelize = new Sequelize('postgres://db_user:db_pass@localhost:5432/findandcount-test', {
dialect: 'postgres'
});
const Property = sequelize.define('properties', {
name: {
type: Sequelize.STRING,
allowNull: false
@DesignByOnyx
DesignByOnyx / clean-form-data.js
Created February 28, 2017 18:51
Express middleware for coercing form-urlencoded data into primitive counterparts
'use strict';
/**
* This file is useful for x-www-form-urlencoded requests where all data is a string.
* If the request uses application/json, this middleware is not needed.
* This loops over all of the data and converts strings to their primitive form,
* basically normalizing numbers, booleans, and null/undefined/'' values.
* This could potentially have side effects, though none were encountered after
* months of using this middleware on a busy project.
*/
.click-collect .form-control.input-lg,
.click-collect .input-group-lg > .form-control,
.click-collect .address-form .input-group-lg > .address-first-name,
.address-form .click-collect .input-group-lg > .address-first-name,
.click-collect .address-form .input-group-lg > .address-last-name,
.address-form .click-collect .input-group-lg > .address-last-name,
.click-collect .address-form .input-group-lg > .address-one,
.address-form .click-collect .input-group-lg > .address-one,
.click-collect .address-form .input-group-lg > .address-two,
.address-form .click-collect .input-group-lg > .address-two,
@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 / all-of-your-models.js
Last active June 16, 2016 22:39
Adjust feathersjs with sequelize to allow models to set up relationships
// Only showing relevant changes
// The folllowing changes must be made in all of your models
var Author = sequelize.define('Authors', {
...
}, {
classMethods: {
// Create a static 'associate' method - will be called later
associate: function (models) {
Author.hasMany(models.Books, { as: 'books' });
@DesignByOnyx
DesignByOnyx / QUnit 2.x update helper
Created July 14, 2015 16:39
Find and replace patterns for updating QUnit tests. Not entirely comprehensive or foolproof, but takes a lot of the manual labor out of upgrading. Run the find/replace combos in order.
(\s{2})(module|test)
$1QUnit.$2
([\d]+), function \((?:assert)?\) \{([\s]+)
function (assert) {$2assert.expect($1);$2
([\"]), function \((?:assert)?\) \{
", function (assert) {
(\s)(equal|notEqual|ok|notOk|propEqual|notPropEqual|deepEqual|notDeepEqual|strictEqual|notStrictEqual|