Skip to content

Instantly share code, notes, and snippets.

View VinayaSathyanarayana's full-sized avatar

Vinaya Sathyanarayana VinayaSathyanarayana

View GitHub Profile
#
# Auth filter /etc/fail2ban/filter.d/nginx-auth.conf:
#
# Blocks IPs that makes too much accesses to the server
#
[Definition]
failregex = ^<HOST> -.*"(GET|POST).*HTTP.*"
ignoreregex =
sudo -i
apt-get update
apt-get install \
apache2-dev \
autoconf \
automake \
build-essential \
bzip2 \
@VinayaSathyanarayana
VinayaSathyanarayana / Example.js
Created November 29, 2017 06:27 — forked from flowck/Example.js
[Keystone.js] Use admin forms outside admin #671
// Model
var keystone = require('keystone'),
Types = keystone.Field.Types;
// Set new model
var Example = new keystone.List('Example', {
nocreate: true
});
// Set the fields of your model
@VinayaSathyanarayana
VinayaSathyanarayana / gulpfile.js
Created November 15, 2017 17:48 — forked from stevenkaspar/gulpfile.js
KeystoneJS SASS Development Gulpfile
/**
* gulp file that will restart keystonejs app and compile sass
*/
'use strict';
var gulp = require('gulp');
var watch = require('gulp-watch');
var shell = require('gulp-shell')
var sass = require('gulp-sass');
@VinayaSathyanarayana
VinayaSathyanarayana / Reserve - model.js
Created November 15, 2017 17:47
Reservation Flow - KeystoneJS help
var keystone = require('keystone');
var Types = keystone.Field.Types;
/**
* Hybrid from the model from the example contact and from SydJS example
*/
/**
* Reservation Model
* =============
@VinayaSathyanarayana
VinayaSathyanarayana / 1-proposal.md
Created November 15, 2017 17:42 — forked from JedWatson/1-proposal.md
Proposal: adding reverse-relationship population to Mongoose (as implemented in KeystoneJS)

I've developed a useful feature in KeystoneJS that lets you populate a relationship from either side, while only storing the data on one side, and am looking for feedback on whether it is something that could / should be brought back into mongoose itself. (It might be possible to add as a separate package but I suspect there'd be too much rewriting of mongoose internals for that to be a good idea).

I've added this as an issue in mongoose for consideration: #1888 but am leaving this gist in place because the examples are easier to read.

I've used Posts and Categories as a basic, contrived example to demonstrate what I'm talking about here; in reality you'd rarely load all the posts for a category but there are other real world cases where it's less unreasonable you'd want to do this, and Posts + Categories is an easy way to demo it.

The problem

The built-in population feature is really useful; not just for

@VinayaSathyanarayana
VinayaSathyanarayana / models-Page.js
Created November 15, 2017 17:41 — forked from timboslice69/models-Page.js
Role based security in KeystoneJS
var keystone = require('keystone'),
// pull in the schemaPermissions lib
// rootRequire is a custom function that fixes the path to always be from the root of the application
schemaPermissions = rootRequire('lib/schemaPermissions'),
Types = keystone.Field.Types;
/**
* Page Model
* ==========
*/
@VinayaSathyanarayana
VinayaSathyanarayana / RepeatableFields.js
Created November 15, 2017 17:41 — forked from ryan-haskell/RepeatableFields.js
Used for expanding KeystoneJS fields, and flattening the response
const getRange = (start, end) => {
let list = []
if (start <= end) {
for (let i = start; i <= end; i++)
list.push(i)
}
return list
}
const RepeatableField = (fields, prefix) => ({