Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Devan devansvd

  • Earth
View GitHub Profile
View auth-interceptor-example.ts
abstract class AuthService {
// Subject tracks the current token, or is null if no token is currently
// available (e.g. refresh pending).
private subject = new BehaviorSubject<string|null>(null);
readonly refreshToken: Observable<any>;
readonly token: Observable<string>;
constructor() {
// refreshToken, when subscribed, gets the new token from the backend,
devansvd / redis_cheatsheet.bash
Created Dec 13, 2018 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION -->
View redis_cheatsheet.bash
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
View angular-serve-static-proxy.js
//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();
devansvd /
Created Oct 8, 2018 — forked from pbojinov/
Two way iframe communication- Check out working example here:

Two way iframe communication

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


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


View my_vs _code_settings.json
"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,
View 1-handlebars-cheatsheet.hbs
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.
1. Expresiones.
1.1 Uso básico.
devansvd / .js
Created Mar 19, 2018
callback to promise example
View .js
const getCourses = () => {
return new Promise( (resolve, reject) => {
Bucket: 'your-bucket-here',
Key: 'your-file.json'
}, function (err, data){
if (err !== null){
devansvd /
Created Mar 4, 2018 — forked from cecilemuller/
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 HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

View lambda-test.js
//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 / nginx.conf
Last active Jan 15, 2018
My backup Nginx configuration
View nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/;
You can’t perform that action at this time.