Skip to content

Instantly share code, notes, and snippets.

View krazylearner's full-sized avatar
🏠
Working from home

Ankur Bansal krazylearner

🏠
Working from home
View GitHub Profile
@krazylearner
krazylearner / express-server-side-rendering.md
Created February 18, 2017 11:45 — forked from joepie91/express-server-side-rendering.md
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
@krazylearner
krazylearner / av.js
Last active April 9, 2017 17:39
testing apache benchmark node.js
***************Without CLuster ***********************
=====================================================
ab -n 1000 -c 50 http://dev.lihaoma.com:4002/v2/offer/58cab6b177bf5930ae85dee4
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking dev.lihaoma.com (be patient)
Completed 100 requests
Completed 200 requests
@krazylearner
krazylearner / directives.js
Created June 15, 2017 06:34 — forked from jakemmarsh/directives.js
AngularJS directive to create a functional "back" button
app.directive('backButton', function(){
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', goBack);
function goBack() {
history.back();
scope.$apply();
@krazylearner
krazylearner / alexa-sdk-https-server-how-to.js
Created August 10, 2017 06:50 — forked from oprog/alexa-sdk-https-server-how-to.js
alexa-sdk how to use it with an express https server
'use strict';
const express = require('express');
const https = require('https');
const fs = require('fs');
const bodyParser = require('body-parser');
const context = require('aws-lambda-mock-context');
// lambda.js contains the lambda function for Alexa as in https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs
var lambda = require('./lambda');

qdqdqdqdq

@krazylearner
krazylearner / gist:c91b300599144d59391e187956b0523f
Created January 14, 2018 16:06
Error handling in node.js
http://goldbergyoni.com/checklist-best-practices-of-node-js-error-handling/
best article