Skip to content

Instantly share code, notes, and snippets.

View sgress454's full-sized avatar

Scott Gress sgress454

View GitHub Profile
@sgress454
sgress454 / pre-commit
Created June 20, 2017 20:20
Pre-commit hook to block commits that change models without adding a migration script
#!/Users/scottmac/.nvm/v6.3.0/bin/node
/**
* Pre-commit hook to prevent commits that change models unless they
* also include a migration file.
*
* To skip, use the `--no-verify` option when committing.
* (useful if you just added a comment to a model)
*/
@sgress454
sgress454 / custom-blueprint.md
Last active March 5, 2022 06:05
Adding a custom blueprint action to all models

Reference: https://gitter.im/balderdashy/sails?at=58be4b1af1a33b62758d57ea

Is there anyway that I can add a method to all routes?

The issue

Given a Sails app with two models User and Pet, how do we create a single controller action foo and have it automatically run on requests for both /user/foo and /pet/foo?

The solution

@sgress454
sgress454 / saving-binary-data-using-waterline.md
Last active February 23, 2017 22:05
Saving binary data in a model using Waterline

Given the appropriate columnType, MySQL and PostgreSQL will handle storing buffers for you.

Model

module.exports = {
  attributes: {
    name: {
      type: 'string',
 },
@sgress454
sgress454 / sails-1.0-removed-deps.md
Created December 2, 2016 00:28
Dependencies removed in Sails 1.0

Dependencies removed in Sails v1.0

Dependency Version
anchor ~0.10.5
connect-flash 0.1.1
ejs-locals 1.0.2
express-handlebars 3.0.0
grunt 1.0.1
grunt-cli 1.2.0
@sgress454
sgress454 / algorithm-for-orderiner g-routes.md
Last active October 20, 2016 16:39
Algorithm for ordering routes

An algorithm for ordering routes

Definition of a "route"

For the purposes of this algorithm, a route is a string containing:

  • An optional HTTP verb (or ALL) prefix, followed by a space, followed by:
  • 1 or more path components, where each path component is:
    • A forward slash /, followed by:
  • A colon : followed by any combination of letters and numbers (a "param"), OR
@sgress454
sgress454 / waterline_issue_repo_instructions.md
Created March 2, 2016 18:27
How to make a repo for reproducing a Waterline issue

The instructions below will work with the regular Git command-line tool or the hub CLI tool (makes things a bit faster).

# Make a new Sails app with a descriptive title
sails new waterline-issue-cant-create-records
cd waterline-issue-cant-create-records

# Install the minimum node modules needed to reproduce the issue, making careful note of versions
# and remembering to use --save
npm install sails-mysql --save
@sgress454
sgress454 / sails_issue_repo_instructions.md
Last active February 24, 2016 11:58
How to make a repo for reproducing a Sails issue

The instructions below will work with the regular Git command-line tool or the hub CLI tool (makes things a bit faster).

# Make a new Sails app with a descriptive title
sails new sails-issue-cant-use-handlebars-layout
cd sails-issue-cant-use-handlebars-layout

# Install the minimum node modules needed to reproduce the issue, making careful note of versions
# and remembering to use --save and --save-exact
npm install [email protected] --save --save-exact
@sgress454
sgress454 / sails_rc5_dependencies.txt
Created December 28, 2015 17:13
Notes on upgrades from v0.11.3 dependencies to now
Following is the list of top-level non-development dependencies with their versions in v0.11.x and notes detailing the version they are upgraded to in v0.12.x (if any) and why. New dependencies (like `consolidate`) have notes explaining the choice of current version.
├── anchor@~0.10.5 (ours)
├── [email protected] -> 0.10.5 (has changelog, lots of bug fixes and good stuff)
├── captains-log@~0.11.11 (ours)
├── [email protected] -> 1.1.2 (no changelog, but seems to be just bugfixes and it's only used for logs)
├── [email protected] -> 2.9.0 (has changelog, bugfixes et al)
├── [email protected] -> 2.29.1 (required by our express version)
├── [email protected] (latest)
├── [email protected] (latest is just react/promises stuff)