Skip to content

Instantly share code, notes, and snippets.

View Praveensamfdo's full-sized avatar

Mututhanthrige Praveen Fernando Praveensamfdo

View GitHub Profile
@Praveensamfdo
Praveensamfdo / Trade-offs between Node.js and PHP for bandwidth critical applications
Last active January 27, 2018 15:17
Trade-offs between Node.js and PHP for bandwidth critical applications
I have worked with node.js for almost an year now, and have used it for following purposes.
1.To design commercial websites with simple 'user-form' submitting, and routing.All the processing is done in server side.
2.Critical applications , where most of the processing is done at the client-side.
When working with node.js, it should be noted that it's a server-side platform. Node.js comes alogn with the Node Package Manager(NPM), s.t.
all the NPM modules only support server side.If a user wants to run a javascript at the client side, he will have the following options.
1.Use Browserify to convert NPM server-side-compatible NPM modules to client-side-compatible NPM modules.
2.Use pure javascript files(without require() function) and store it tin the static folder , then call the pth of the static .js file
#use the following commnad to browserify .js files, which includes functions
browserify main.js --standalone exampleFunction > bundle.js
#when creatin main.js file the following format should be followed
//--start
module.exports = exampleFunction;
function exampleFunction()
{
//--function body
@Praveensamfdo
Praveensamfdo / passport.js
Created February 7, 2017 07:33 — forked from manjeshpv/passport.js
Passport.js using MySQL for Authentication with Express
// config/passport.js
// load all the things we need
var LocalStrategy = require('passport-local').Strategy;
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
@Praveensamfdo
Praveensamfdo / Setting up mysql in node.js
Last active January 27, 2018 15:19
Setting up mysql in node.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host:'localhost',
user:'root',
database:'mysampleDB'
});
connection.connect(funcction(err){
@Praveensamfdo
Praveensamfdo / Setting up MongoDB server on a local machine
Last active January 27, 2018 15:20
Setting up MongoDB server on a local machine
#install MongoDB
# install from this link 'https://www.mongodb.com/download-center?jmp=nav#community'
#navigate to 'C:\Program Files\MongoDB\Server\3.4\bin'
#open cmd, run following commands in the given order
mongod
mongo
#if mongod is crashing, the reason is there's no folder to store databases.Type the following in the same root
mkdir C:\data\db
@Praveensamfdo
Praveensamfdo / Easily create express apps
Last active March 25, 2018 14:51
Easily create express apps
#install express package globally
npm install -g express
#if the above commnand doesn't work try this
npm install -g express-generator
#go to your app dir
#this will install express package in the local directory
express