Skip to content

Instantly share code, notes, and snippets.

View devansvd's full-sized avatar
🤗
Available

Devan devansvd

🤗
Available
View GitHub Profile
{
"window.zoomLevel": 0,
"workbench.iconTheme": "vscode-great-icons",
"workbench.startupEditor": "newUntitledFile",
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen": false,
"editor.wordWrap": "off",
"git.enabled": false,
"git.autofetch": false,
"telemetry.enableTelemetry": false,
Handlebars es un sistema de plantillas web semantico iniciado por Yehuda Katz en el 2010.
Handlebars.js es una extensión de Mustache, y además de renderear plantillas propias de Handlebars,
puede renderear plantillas Mustache.
More: http://handlebarsjs.com/
http://mustache.github.io/mustache.5.html
1. Expresiones.
1.1 Uso básico.
@devansvd
devansvd / .js
Created March 19, 2018 10:53
callback to promise example
const getCourses = () => {
return new Promise( (resolve, reject) => {
S3.getObject({
Bucket: 'your-bucket-here',
Key: 'your-file.json'
}, function (err, data){
if (err !== null){
reject(err)
}
resolve(JSON.parse(data.Body.toString('utf-8')))
@devansvd
devansvd / letsencrypt_2017.md
Created March 4, 2018 12:35 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

//callback test
function getInfo(options, callback){
http.get(options, function(res) {
console.error("Got response: " + res.statusCode);
res.on("data", function(chunk) {
console.error("BODY: " + chunk);
text = '' + chunk;
return callback(text);
});
}).on('error', function(e) {
@devansvd
devansvd / nginx.conf
Last active January 15, 2018 11:42
My backup Nginx configuration
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@devansvd
devansvd / RecursiveLoop.js
Created December 28, 2017 12:18
Recursive loop syntax
//Recursive Loop Syntax
function recursiveLoop(data, inputlength) {
if (inputlength >= 0) {
var currentdata = data[inputlength];
inputlength = inputlength - 1;
recursiveLoop(data,inputlength);
}
else{
//Response here
@devansvd
devansvd / nodejs-boiler-code.js
Last active April 28, 2020 12:57
Nodejs Boiler plate code
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.all('*',function(req,res,next){
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'OPTIONS,GET,POST,PUT,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');