Skip to content

Instantly share code, notes, and snippets.

View devansvd's full-sized avatar
🤗
Available

Devan devansvd

🤗
Available
View GitHub Profile
@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');
@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 / 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;
//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 / 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.

@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')))
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.
{
"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,
@devansvd
devansvd / README.md
Created October 8, 2018 10:10 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

//Angular 2 above application static server
const http = require('http');
const express = require('express');
const proxy = require('http-proxy-middleware');
const path = require('path');
const app = express();
app.use(express.static('client'));