Skip to content

Instantly share code, notes, and snippets.

View ebarault's full-sized avatar
💫

Eric Barault ebarault

💫
View GitHub Profile
@ebarault
ebarault / git-cheatsheet.md
Last active February 18, 2019 15:43
Git cheatsheet

resync local branch with remote branch

git fetch origin
git reset --hard origin/master
git clean -f -d

delete last commit(s)

# last commit

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@ebarault
ebarault / protectUserId.js
Created March 9, 2017 13:08 — forked from skleeschulte/protectUserId.js
LoopBack 3 boot script for protecting userId properties on custom models
'use strict';
/**
* Add before safe hook and validation to all custom models with an userId property to prevent changing userId
* properties by non-admin users.
*/
const USER_ID_PROPERTY = 'userId';
const INVALID_USER_ID = -1;
// started from https://github.com/strongloop/loopback/issues/651
'use strict';
let _ = require('lodash');
module.exports = function (Model, options) {
if(Model && Model.sharedClass) {
let enableFromACLs = options.enableFromACLs === false? false: true;
@ebarault
ebarault / disable-remote-methods.js
Last active January 24, 2018 09:43 — forked from drmikecrowe/DisableAllMethods.js
Loopback mixin to disable or expose methods
// based on https://github.com/strongloop/loopback/issues/651#issuecomment-259540469
'use strict';
module.exports = function (Model, options) {
if(Model && Model.sharedClass) {
var methodsToExpose = options.expose || [];
var methodsToHide = options.hide || [];