Skip to content

Instantly share code, notes, and snippets.

💭
Find me by the tumtum tree

Jarrod nahanil

💭
Find me by the tumtum tree
Block or report user

Report or block nahanil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View config__uploads.js
module.exports.uploads = {
adapter: require('skipper-minio'),
endPoint: 'sfo2.digitaloceanspaces.com',
useSSL: tre,
accessKey: 'key',
secretKey: 'key',
allowedFileTypes: ['image/jpeg', 'image/png', 'image/gif'],
maxBytes: 10 * 1024 * 1024
};
View api_controllers_create.js
module.exports = {
friendlyName: 'Create',
description: 'Create something.',
inputs: { },
exits: {
createFailed: {
statusCode: 500
}
View config__models.js
// ...
attributes: {
id: {
type: 'number',
autoIncrement: true,
},
createdAt: {
type: 'ref',
View config__env__production.js
/**
* Production environment settings
* (sails.config.*)
*
* What you see below is a quick outline of the built-in settings you need
* to configure your Sails app for production. The configuration in this file
* is only used in your production environment, i.e. when you lift your app using:
*
* ```
* NODE_ENV=production node app
View boom.js
function purgeOldMail () {
Email.destroy({
createdAt: { '<=': Date.now() - sails.config.custom.keepMailTime }
}).exec((err) => {
if (err) {
sails.log.error(`Unable to purge old mail:`, err.stack)
}
timer = setTimeout(purgeOldMail, 30 * 1000)
})
@nahanil
nahanil / Dockerfile
Created Sep 26, 2019
Simple node.js Dockerfile
View Dockerfile
FROM node:10-alpine
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
View nginx-app-basic.com
server {
listen 80;
server_name myapp.com;
location / {
# Pass off API and socket requests to the app server
proxy_pass http://127.0.0.1:1337;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
@nahanil
nahanil / layout.ejs
Last active Sep 8, 2019
Sails page title
View layout.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<title><%= typeof data !== 'undefined' && data.title ? data.title + ' | ' : (typeof title == 'undefined' ? '' : title + " | " )%><%= sails.config.appName %> | Chinese - English Dictionary &amp; Mandarin Learning Resources</title>
...
View poopy.js
// Complete the arrayManipulation function below.
function arrayManipulation(n, queries) {
let array = Array(n).fill(0)
let max = -Infinity
for (const [start, end, summand] of queries) {
for (let i = start - 1; i < end; i++) {
array[i] += summand
if (array[i] > max) {
max = array[i]
@nahanil
nahanil / api__forbidden.js
Created Aug 18, 2019
Sails: Custom response handler
View api__forbidden.js
/**
* forbidden.js
*/
module.exports = function unauthorized(data) {
sails.log.verbose('Ran custom response: res.forbidden()');
return this.res
.status(403)
.json(data ? data : { message: `You don't have permission to do that` } );
};
You can’t perform that action at this time.