Skip to content

Instantly share code, notes, and snippets.

@Jero786
Jero786 / react live templates webstorm
Last active June 15, 2019 15:17
Webstorm - Live Templates
// rt
render(<$ELEMENT$ $ATTRIBUTE$='$TEXT$'/>).getByText(/$TEXT$/);
$END$
// itrt
it('should render properly the $ATTRIBUTE$ value', () => {
render(<$ELEMENT$ $ATTRIBUTE$='$TEXT$'/>).getByText(/$TEXT$/);
});
$END$
@Jero786
Jero786 / gist:bdde50951756b0ab3deafa6bd634274b
Created June 13, 2019 23:00
NodeJS + Mongoose + Mongoose-Crudify
const express = require('express');
const mongoose = require('mongoose');
const mongooseCrudify = require('mongoose-crudify');
const app = express();
const bodyParser = require('body-parser');
const PORT = process.env.PORT || 3000;
mongoose.connect('mongodb://localhost/demo', {useNewUrlParser: true})
.then(() => console.log('Connection successfull'))
.catch(err => console.error(err));
const express = require('express');
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/demo', {useNewUrlParser: true})
.then(() => console.log('Connection successfull'))
.catch(err => console.error(err));
const BlogSchema = mongoose.Schema({
name:String,
email:String,
@Jero786
Jero786 / gist:8189f6f28f99a209c14d73760bc19495
Last active October 15, 2018 16:27
A simple flatten array
/**
* Given a array of array values, will return a new instance with a flatten array.
*
* @param {Array} The array which will be flatten
* @param {Array} The new flatten array (private)
* @param {number} A position index that use to traverse given array. (private)
* @return {Array} The new array flatten
* @public
*/
function flatten(numbers, result, index) {