- Modify & run
dump-sequelize-schema.js
.- It currently uses a few
lodash
methods, so be sure to temporarily install them—or if you feel up to it you can rewrite the script so they're not needed. npm i lodash.sortby lodash.pick lodash.omit lodash.mapvalues
- It currently uses a few
- Inspect
sequelize-schema.json
and make sure it appears represent all of your tables, attributes, indexes, constraints, references, etc... - When you are satisfied, copy and rename
sequelize-schema.json
file into amigration-extras/
directory that is next to yourmigrations/
. Name itinitial-sequelize-schema.json
.migration-extras/
- ->
initial-sequelize-schema.json
- ->
migrations/
- (this folder should probably be empty)
- Run
sequelize migration:create
and then copy the contents of2018XXXXXXXXXX-initial-migration.js
into the newly generated migration script. No additional modifications are required if y
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async function generateReplies(document) { | |
// https://conventionalcomments.org/#labels | |
const LABEL = { | |
praise: "praise", | |
nitpick: "nitpick", | |
suggestion: "suggestion", | |
issue: "issue", | |
todo: "todo", | |
question: "question", | |
thought: "thought", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
plex: | |
image: linuxserver/plex | |
container_name: plex | |
volumes: | |
- /path/to/plex/config:/config | |
- /path/to/plex/Movies:/data/movies | |
- /path/to/plex/Shows:/data/tvshows | |
- /path/to/plex/transcode:/data/transcode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code to encrypt data in sequelize fields | |
// We are using ascii85 as a way save on storage. Also, note that | |
// the space delimiter we are using is a bit of an abuse since in | |
// normal cases ascii85 will skip over it, but since we are using | |
// after encoding and before encoding, it shouldn't be an issue. | |
// | |
// Fields are broken down to facilitate unit testing. | |
// | |
// based on code here: http://vancelucas.com/blog/stronger-encryption-and-decryption-in-node-js/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 0-1 knapsack problem | |
For an overall introduction to knapsack problem, see https://en.wikipedia.org/wiki/Knapsack_problem | |
Function name: knapsack | |
Param: | |
items: an array of {w: v:} (where 'w' stands for weight, and 'v' stands for value) | |
capacity: a positive integer number | |
Will return max sum value that can reach, and the chosen subset to add up to the value. |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// === Arrays | |
var [a, b] = [1, 2]; | |
console.log(a, b); | |
//=> 1 2 | |
// Use from functions, only select from pattern | |
var foo = () => [1, 2, 3]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var redis = require("redis") | |
, subscriber = redis.createClient() | |
, publisher = redis.createClient(); | |
subscriber.on("message", function(channel, message) { | |
console.log("Message '" + message + "' on channel '" + channel + "' arrived!") | |
}); | |
subscriber.subscribe("test"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Sequelize = require('sequelize') | |
var sequelize = new Sequelize('sequelize_test', 'root') | |
//Note that the model definition does not have "fullName" | |
var User = sequelize.define('User', { | |
email: Sequelize.STRING, | |
firstName: Sequelize.STRING, | |
lastName: Sequelize.STRING, | |
}, | |
{ |