Skip to content

Instantly share code, notes, and snippets.

@ifyoumakeit
ifyoumakeit / github-conventional-comments.js
Last active May 6, 2024 14:31
GitHub Conventional Comments (instructions to install in comment below code)
(async function generateReplies(document) {
// https://conventionalcomments.org/#labels
const LABEL = {
praise: "praise",
nitpick: "nitpick",
suggestion: "suggestion",
issue: "issue",
todo: "todo",
question: "question",
thought: "thought",
@scryptonite
scryptonite / 0_README.md
Last active October 24, 2019 01:52
Dumps all Sequelize models to JSON to help with creating the first migration script.
  1. 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
  2. Inspect sequelize-schema.json and make sure it appears represent all of your tables, attributes, indexes, constraints, references, etc...
  3. When you are satisfied, copy and rename sequelize-schema.json file into a migration-extras/ directory that is next to your migrations/. Name it initial-sequelize-schema.json.
    • migration-extras/
      • -> initial-sequelize-schema.json
    • migrations/
      • (this folder should probably be empty)
  4. Run sequelize migration:create and then copy the contents of 2018XXXXXXXXXX-initial-migration.js into the newly generated migration script. No additional modifications are required if y
@Aghassi
Aghassi / docker-compose.yml
Last active April 1, 2024 21:03
LinuxServer Docker Compose: Plex, Sonarr, Radarr, NZBGet, Let's Encrypt, Time Machine
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
@ajmas
ajmas / sequelieze-field-encrypt.js
Last active February 20, 2022 11:07
Code to encrypt a Sequelize fields
// 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/
@lqt0223
lqt0223 / knapsack.js
Created April 11, 2017 11:52
20 0-1 Knapsack problem in JavaScript
/* 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.
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@mikaelbr
mikaelbr / destructuring.js
Last active April 25, 2024 13:21
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@reu
reu / pub-sub.js
Created April 9, 2013 01:51
node.js redis pub-sub example
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");
@pranildasika
pranildasika / gist:2964211
Created June 21, 2012 06:26
Virtual fields using getter and setter methods in sequelize
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,
},
{