Skip to content

Instantly share code, notes, and snippets.

View gabmontes's full-sized avatar

Gabriel Montes gabmontes

View GitHub Profile

Express y plantillas

Express nos brinda la posibilidad de utilizar plantillas para servir el contenido HTML de nuestros sitios web. Para ello existe un mecanismo mediante el cual se configura la instancia de Express que estemos utilizando para utilizar un motor de plantillas determinado. Este motor realizará la tarea de, partiendo de una plantilla HTML y un objeto de configuración/contenido, generar el HTML que será servido a los clientes.

Dentro de los motores de plantillas más conocidos se encuentran:

  • Jade es el más popular y tiene una sintaxis muy limpia para escribir las plantillas
  • EJS utiliza un esquema muy similar a ASP para definir las plantillas

Jade

@gabmontes
gabmontes / delete-all-my-gists.js
Last active December 3, 2023 08:39
Delete all your gists
var async = require('async');
var GitHubApi = require('github');
var github = new GitHubApi({
version: '3.0.0',
protocol: 'https'
});
github.authenticate({
type: 'basic',
@gabmontes
gabmontes / index.js
Created May 9, 2016 15:11
Gists cleaner
var async = require('async');
var GitHubApi = require('github');
var github = new GitHubApi({
version: '3.0.0',
protocol: 'https'
});
github.authenticate({
type: 'basic',
@gabmontes
gabmontes / test-bookshelf-paranoia.js
Created June 9, 2016 18:37
Test file to reproduce an issue with polymorphic relationships and soft deletes using bookshelf and bookshelf-paranoia
const config = {
client: 'pg',
connection: {
host : 'localhost',
port : 5432,
user : 'user',
password : 'pass',
database : 'test'
}
}
const config = {
client: 'pg',
connection: {
host: 'localhost',
port: 5432,
user: 'user',
password: 'pass',
database: 'test'
},
debug: false
@gabmontes
gabmontes / babel-presets-transforms-matrix.md
Created October 19, 2016 15:41
Summary of babel presets to transforms matrix

Presets to transforms

Data as of 18-oct-2016

| es2015 | es2016 | es2017 | latest | latest-minimal(*) | stage-3 | stage-2 | stage-1 | stage-0 --- |:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---: check-es2015-constants | x | | | x | x | | | | syntax-dynamic-import | | | | | | | x | | syntax-trailing-function-commas | | | x | x | x | x | | | transform-async-generator-functions | | | | | | x | | |

@gabmontes
gabmontes / not-jquery.js
Last active November 16, 2016 15:23
A partial (re)implementation of jQuery API as a polyfill for learning and teaching purposes
/**
* not-jquery
*
* A partial (re)implementation of jQuery API as a polyfill for learning and
* teaching purposes.
*
* https://gist.github.com/gabmontes/535a7b3b059b2a301a55b43e90ee0101
*/
// eslint-disable-next-line no-extra-semi
@gabmontes
gabmontes / my-top-starred-repos.js
Last active May 28, 2018 03:03
Automagically obtain your top starred repos as an Markdow table
const GitHubApi = require('@octokit/rest');
function pick(props) {
return function (object) {
const result = {}
Object.keys(object).filter(prop => props.includes(prop)).forEach(function (prop) {
result[prop] = object[prop]
})
return result
}
@gabmontes
gabmontes / not-react.js
Created November 16, 2016 15:27
A minimal (re)implementation of ReactDOM for learning and teaching purposes.
/**
* not-react
*
* A minimal (re)implementation of ReactDOM for learning and teaching purposes.
*
* https://medium.com/@gab_montes/react-in-200-bytes-28156e714165
*/
// eslint-disable-next-line no-extra-semi
;(function (global) {
@gabmontes
gabmontes / btc-balance.js
Last active November 28, 2016 15:30
Sum up the balances of a group of bitcoin addresses
const { Insight } = require('bitcore-explorers')
const promisify = require('tiny-promisify')
const addresses = [
/* bitcoin addresses here! */
]
const insight = new Insight()
const getUnspentUtxosAsync = promisify(insight.getUnspentUtxos.bind(insight))