Skip to content

Instantly share code, notes, and snippets.

View epinapala's full-sized avatar

Eswar Pinapala epinapala

View GitHub Profile
@epinapala
epinapala / README.md
Created September 26, 2019 18:39 — forked from hofmannsven/README.md
Command Line Cheatsheet
@epinapala
epinapala / example.js
Created May 31, 2018 16:38 — forked from ignlg/example.js
Fixes "TypeError: JSON.stringify cannot serialize cyclic structures" error when exporting to JSON a KeystoneJS model/list including virtuals.
var modelCleanCyclic = require('./modelCleanCyclic');
var Example = new keystone.List('Example', {});
Example.schema.set('toJSON', {
virtuals: true,
transform: modelCleanCyclic.transformer
});
@epinapala
epinapala / composer.bat
Created May 20, 2018 18:32 — forked from JCook21/composer.bat
Quick Batch file to add a 'composer' command to windows.
@echo off
if "%PHPBIN%" == "" set PHPBIN=C:\path\to\PHP\executable\dir\.\php.exe
"%PHPBIN%" "C:\path\to\composer.phar" %*
@epinapala
epinapala / ._readme
Created April 20, 2018 19:14 — forked from nikolowry/._readme
Customize Keystone
This GIST illustrates a hack to allow for configurable backend-url and admin styles in Keystone.js
New deps introduced:
- node-dir
- shelljs
New directory structure after running "yo keystone":
.
|____admin
| |____assets

#How does KeystoneJS render it's Admin UI

KeystoneJS is an open source framework for developing database-driven websites, applications and APIs in Node.js. It's built on Express and MongoDB.The easiest way to get started with KeystoneJS is to use Yeoman Generator.yo keystone will scaffold a new KeystoneJS project for you, and offer to set up blog, gallery, and enquiry (contact form) models + views.If you'd like to try the demo at first,here it is.

When I wrote this,keystone's stable version is 0.2.39,and 0.3.0 not published yet,so if you have a different version of KeystoneJS,the content maybe different.

##Generate a KeystoneJS Project

First up, you'll need Node.js >= 0.10.x and MongoDB >= 2.4.x installed. Then, install the Keystone generator:

@epinapala
epinapala / gist:f07f01643208ca90934550e08d1ff789
Created April 19, 2018 23:36 — forked from rturk/gist:f5ff8a16124365b8a113
Mongoose Virtual field async await
Schema.virtual('comments')
//Returns comment owned by this product
.get(
async obj => await Comment
.find({ 'owner': this._id, deleted: { $ne: true } })
.sort('-likesCount -date_modified')
.limit(6)
.exec()
);
@epinapala
epinapala / keystone.js
Created April 9, 2018 05:55 — forked from JedWatson/keystone.js
Example of how to integrate node-i18n with a KeystoneJS app (using yo keystone generated site as a basis) - see https://github.com/mashpie/i18n-node for more docs.
// Simulate config options from your production environment by
// customising the .env file in your project's root folder.
require('dotenv')().load();
// Require keystone and i18n
var keystone = require('keystone'),
i18n= require('i18n');
// Initialise Keystone with your project's configuration.
// See http://keystonejs.com/guide/config for available options
@epinapala
epinapala / raspbian-python3.6.rst
Created March 18, 2018 20:55 — forked from dschep/raspbian-python3.6.rst
Installing Python 3.6 on Raspbian

Installing Python 3.6 on Raspbian

As of January 2018, Raspbian does not yet include the latest Python release, Python 3.6. This means we will have to build it ourselves, and here is how to do it. There is also an ansible role attached that automates it all for you.

  1. Install the required build-tools (some might already be installed on your system).
@epinapala
epinapala / gist:91e714b3da3afcefb6ec74733caa6918
Created April 26, 2017 18:51 — forked from kagemusha/gist:5866759
Using Debugger with Grunt
version: grunt-cli v0.1.8
1. Install node-inspector globally (-g)
npm install -g node-inspector
2. Add debugger statements to your code
3. Run your grunt task in debug mode