Labels

Tuesday, February 14, 2017

NodeJS Quick Pointers

Here we'll cover quick notes on Node.JS
-------------------------------------------------------

Deployment Alternates:

 - Heroku
 - Nodejitsu (https://www.nodejitsu.com/documentation/)
 - Modulus
 - Joynet
 - AWS


·         ECMA Browser/Server Compatibility Matrix - Kagnax : https://kangax.github.io/compat-table/es6/
·         Passport Authentication (Authentication Middleware for Node.js)- http://passportjs.org/
o   npm install passport --save
o   npm install passport-local --save
o   npm install express-session --save
o   npm install connect-flash --save
·         IIFE – Immediate Invoke Function Expression

·         Bower: https://bower.io/
·         Package Manager for Web.
·         Bower can manage components that contain HTML, CSS, JavaScript, fonts or even image files.
·         Bower doesn’t concatenate or minify code or do anything else - it just installs the right versions of the packages you need and their dependencies.
·         Bower keeps track of these packages in a manifest file, bower.json
·         Bower is optimized for the front-end. If multiple packages depend on a package - jQuery for example - Bower will download jQuery just once. This is known as a Flat Dependency Graph and it helps reduce page load.

·         npm install bower –g
·         Created .bowerrc file to set Bower directory. (e.g. public/javascripts)
·         bower init to create bower.json file
·         Install Angular (Folders will be auto created under public/javascripts folder)
·         bower install angular –save
·         bower install angular-route –save

·         JWT (JSON Web Token)
·         JSON-based open standard for creating access tokens that assert some number of claims.
·         For example, a server could generate a token that has the claim "logged in as admin" and provide that to a client.
·         npm install jsonwebtoken --save


·         Mongoose
·         npm install mongoose --save
·         Creating Schema
·         Schema Types
·         String
·         Number
·         Date
·         Buffer
·         Boolean
·         Mixed
·         ObjectId
·         Array

·         Built in Validators
·         All Schema Types - required, unique
·         Number - min, max
·         String - enum, match, maxlength, minlength

·         Methods available to use
·         Read
·         find({}) - Find All
·         findOne({username:'abc'}) - Find One
·         findById(1) - Find By ID
·         Query
·         find({}).where('')

·         Update
·         Find the Record
·         Change the property Value
·         Call Save()

·         findOneAndUpdate({username:'abc'},{email:'xyz@test.com'})
·         findByIdAndUpdate(1,{email:'xyz@test.com'})

·         DELETE
·         remove()
·         findOneAndRemove({username:'abc'})
·         findByIdAndRemove({username:'abc'})





·         MEAN Stack:
·         Mongo DB, Express JS, Node JS, Angular JS,  (MEAN Stack)
·         Server: (M E N)
·         Client: (Angular / jQuery / JavaScript / React / KnockOut / Backbone)


  • ·         Web Frameworks
    • o   Express
    • o   Koa
  • ·         Learnjade.com
  • ·         Mongodb.com
  • ·         Robomongo (Client to  use Mongo DB Server)
  • ·         Monk (Node js Mongo db driver)
  • ·         Mongoose (ORM Model)
  • ·         Browser/AppEngine/Runtime Grid

Browser
Layout Engine
Runtime
IE
Trident
Chakra
FF
Gecko
SpiderMonkey
Chrome
Webkit
V8

·         Language/Other Matrix:
Language
C#
JAVA
JAVASCRIPT (MEAN Stack)
Core FW
.Net FW
JDK
Node.js
Runtime
CLR
JVM
Node.exe (v8 Engine)
Web FW
ASP .Net
JSP
Express JS (MVC)

ASP .NET MVC
SPRING


ASP .Net Web API
Java WebServices

Database
SQL Server
Oracle
Mongo DB
Client FW
Angular JS
Angular JS
Angular JS

·         Node.JS Event Loop:



·         When to choose Node.JS
·         Chat/Messaging
·         Real Time Applications
·         High Concurrent Aplications
·         Communications Hubs
·         Co-ordinators
·         Intelligent Proxies
·         Communication Hubs

·         Use Node.JS For:
·         Web Application
·         WebSocket Server
·         Ad Server
·         Proxy Server
·         Streaming Server
·         Fast File Upload client
·         Any Real Time Data Apps
·         High I/O
  

·         Database Matrix
RDBMS
MongoDB (No SQL)
Database
Database
Table
Collection
Row / Tuple
Document
Column
Field
Join
Embedded Documents
Primary Key
Primary Key (_id)
Oracle / SQL Server
Mongod
Sqlplus / SSMS
Mongo (RoboMongo)



Friday, January 20, 2017

Common HTTP Error Codes

When you surf the web, it works on a request-response system. You request a resource, such as  web page or an image, and you get back a response, or your browser does, at least. Thanks to the “http:” you place before a URL when you type in the browser’s address bar, requests and responses have a predefined structure. As defined by the Hypertext Transfer Protocol (HTTP), an important part of that structure is a status code.

 

Introducing HTTP Status Codes

 

Status codes are three-digit numbers.

·         Code starts with a 1. These represent informational messages. These are rarely seen.

·         Code starts with a 2, as in 200, that represents a successful response to the request.

·         Code starts with a 3 in form 3xx represents a redirection response.

·         Error codes at the 400 level mean there was a client-side error — think of something like the user typing the wrong URL in the address bar.

·         Error codes at the 500 level mean there was a server-side error — think of something like the database server going down or perhaps running out of disk space.

 

Five of the most popular error codes are 403, 404, 500, 503, and 504.

 

404 Not Found

The most common error code you run into is a 404 error. The 404 status code means the requested resource is no longer available or, more specifically, just not found. Was it ever available there? You don’t know. You do know it isn’t available there now.

What are some of the reasons for a 404 error? Typos are a common reason for getting a 404 error. A missing or extra letter in a typed-in url, or a wrong domain name can often result in a 404 error. Another reason for 404 errors isn’t typos; it is the aging of the web. When someone writes an article or blog, that person might link to a secondary source to provide additional information for the article. Now imagine revisiting said article six months or six years later. If what was linked to is no longer on the web, a 404 error will be generated when you click on the link in the browser.

 

403 Forbidden

Another common client-side response status code is 403. Getting a 403 status code back from an HTTP request means access to the resource is forbidden. This is not an authentication problem; those are 401 (unauthorized) errors. One common reason for 403 errors is the server maintaining a whitelist of machines that can access that system and the user’s machine not being on it. If the client’s certificate is no longer valid (or is just plain missing), that’s another reason for a 403 error response. There typically is no recovery from these, short of trying from a different machine. Finally, there’s also the possibility of wrong permissions associated to files. Often in Linux and sometimes in Windows, a webserver will not have access to website files because of faulty permissions. This will also result in a 403 error. The server owner will need to change the file permissions to fix this.

 

500 Internal Server Error

Moving over to the server-side error codes, the 500 error is the catchall. When none of the other 500 error codes make sense, or if the programmer is just lazy and doesn’t identify the specific problem, a 500 status code is returned. Typically, you can retry the request attempt again and possibly get a different response. Of course, retrying attempts that involved a shopping cart that resulted in a 500 error could result in a duplicate order, so tread carefully there.

 

503 Service Unavailable

Like many of the 500-level error codes, the 503 (service unavailable) status code could be a temporary problem. It basically means the web server isn’t available. Why? You don’t know. Perhaps the web server just restarted and is in the middle of initialization. Perhaps it is overloaded and can’t handle any more concurrent requests. Or perhaps it is just down for maintenance. Retrying the request could work or could return another 5xx error.

 

504 Gateway Timeout

The final of the top five error codes is the 504 status, indicating a gateway timeout. The name says it all. A proxy server needs to communicate with a secondary web server, such as an apache server, and access to that server timed out. There could be a DNS issue, a network device might be down, or the other machine could just be overly busy and unable to process the request in a timely fashion. This can only happen in a setup where a caching or proxy server is directly serving the webpage and the actual webserver behind it is unreachable. As with the other 5xx-level errors, just retrying the request could result in a successful response.

In the End

 

HTTP and its associated secure HTTPS are the primary protocols for browsing on the web. Each web request results in a response with an associated status code. Status codes fall into classes: informational (1xx), success (2xx), redirection (3xx), client errors (4xx), server errors (5xx). You try to get success responses with your requests, but it doesn’t always happen. Learn how to recover from these error codes, so you can move on.

 

Hope this helps.

 

Regards,

Arun

Friday, August 12, 2016

Branching Strategies for Agile/Scrum teams

Below are four different branching strategies, which is a direct fit for Agile Team.

 

·         Branching by Feature (Kanban Model)

·         Branching by Sprints (Scrum Model)

·         Branching by Sprints & Epic Span Across Sprints(Scrum Model)

·         Branching by Hotfix during Sprints (Scrum/Kanban Model)

 

 

 

 

 

 

 

Watch this video for more details: https://www.youtube.com/watch?v=SBuxRiPk2Zg

 

Regards,

Arun Manglick

 

Tuesday, July 26, 2016

Bitcoin - Basics

Bitcoin is a digital currency created in 2009 (Satoshi Nakamoto).

Bitcoin offers the promise of lower transaction fees than traditional online payment mechanisms and is operated by a decentralized authority, unlike government issued currencies.

 

There are no physical Bitcoins, only balances associated with public and private keys.

These balances are kept on a public ledger, along with all Bitcoin transactions, that is verified by a massive amount of computing power.

 


BREAKING DOWN 'Bitcoin'

 

Bitcoin balances are kept using public and private "keys," which are long strings of numbers and letters linked through the mathematical encryption algorithm that was used to create them.

·         Public key (comparable to a bank account number) serves as the address which is published to the world and to which others may send Bitcoin.

·         Private key (comparable to an ATM PIN) is meant to be a guarded secret, and only used to authorize Bitcoin transmissions.

 

 

 

Style notes: According to the official Bitcoin Foundation, the word "Bitcoin" is capitalized in the context of referring to the entity or concept, whereas "bitcoin" is written in the lower case when referring to a quantity of the currency (e.g. "I traded 20 bitcoin"). The currency can be abbreviated to BTC or, less frequently, XBT. The plural form of the word can be either "bitcoin" or "bitcoins."

To learn more about this cryptocurrency, check out How do I buy Bitcoins?

 

 

What is Bitcoin?

In non-technical language, Bitcoin is a digital currency in which transactions can be performed without the need for a credit card or central bank.

It's designed to enable users to send money over the Internet in a very simple and efficient way.

 

Who runs Bitcoin? What is the company behind Bitcoin? 

In short, no one runs Bitcoin.

Bitcoin is run collectively by the users who uses the Bitcoin Client, and any changes to the Bitcoin system have to be approved by the majority of users before they are implemented. 

 

What is a Bitcoin address?

A Bitcoin address is a unique identifier which allows you to receive Bitcoins.

With PayPal you send funds to an email address, and similarly with Bitcoin you send funds to a Bitcoin address.

For example, this is one of our Bitcoin addresses:  1JArS6jzE3AJ9sZ3aFij1BmTcpFGgN86hA

Please verify that you have copied the destination address exactly before sending Bitcoins to it.   Bitcoin transactions are not reversible!

 

What is a private key?

A private key is a secret code which allows the user to prove his ownership of his Bitcoins. 

Every Bitcoin address has a matching private key, which is saved in the wallet file of the person who owns the balance.

 

The private key is mathematically related to the Bitcoin address, and is designed so that the Bitcoin address can be calculated from the private key, but importantly, the same cannot be done in reverse.

Please keep your private keys safe, and make periodic backups to prevent the loss of Bitcoins.  Anyone with your private keys can spend your Bitcoins!

 

What are the fees involved?

The transaction is usually free if the sum transacted is greater than 0.01 BTC.

A token sum is imposed to provide some incentive to the miners to include the transaction in the blockchain..

At the moment, many transactions are typically processed in a way where no fee is expected at all, but for transactions which draw coins from many Bitcoin addresses and therefore have a large data size, a small transaction fee is usually expected. Please see the bitcoin wiki for calculating minimum fees.

 

What does 'unconfirmed' mean? 

It means that the transaction has not yet been included in the blockchain, and is still reversible. A transaction typically takes around 10 minutes to be confirmed. When that happens, it is said that one confirmation has occurred for the transaction. With each subsequent block that is found, the number of confirmations is increased by one. To protect against double spending, a transaction should not be considered as confirmed until a certain number of confirmations is seen. 

 

Who are the 'Miners'? 

Miners are individuals who run computer systems to repeatedly calculate hashes with the intention to create a successful block and earn coins from transaction fees and new coins created with the block itself.

The term references an analogy of gold miners who dig gold out of the ground and thus 'discover' new gold that can be used to create new coins, with a similar kind of discovery occurring with a successful hash to create new Bitcoins. 

 

The independent individuals and companies who own the governing computing power and participate in the network, also known as "miners," are motivated by mining rewards (the release of new Bitcoin) and transaction fees paid in Bitcoin. These miners can be thought of as the decentralized authority enforcing the credibility of the Bitcoin network.

 

 

Is there a limit to the amount of Bitcoins generated?

The number of Bitcoins in existence will never exceed 21 million.

To see how many Bitcoins are in circulation, please go to: https://blockchain.info/charts/total-bitcoins

 

One bitcoin is divisible to eight decimal places (100 millionth of one bitcoin), and this smallest unit is referred to as a Satoshi.

If necessary, and if the participating miners accept the change, Bitcoin could eventually be made divisible to even more decimal places.

 

How much does a Bitcoin cost?

The current market price for a Bitcoin is always changing due to the supply and demand for it.

Bitcoins are traded at Bitcoin Exchanges. A historical Bitcoin price chart can be found at: https://blockchain.info/charts/market-price

 

What is a Bitcoin Client?

Bitcoin clients are the base level of technology for conducting Bitcoin transactions, and they store the keys needed to conduct a Bitcoin transaction.

They come in multiple flavors, and are customized to fit different niches.

 

1.       The Bitcoin-QT Client (Downloadable at http://bitcoin.org/) is the original software written by Satoshi Nakamoto, the project's founder. If you aren't sure which program to pick, this is a good bet. It is suited for enthusiasts, merchants, miners, developers and people who want to help support the project. 

2.       The MultiBit Client (Downloadable at https://multibit.org/) is fast and easy to use, even for people with no technical knowledge. It is also able to import Blockchain.info's wallet backups (Multibit version 5.17 and earlier), making it a versatile tool for all kinds of users.

3.       The Electrum Client (Downloadable at http://electrum.org/) focuses at speed, with low resource usage and simplifying Bitcoin usage. Startup times are instant because it operates in conjunction with high-performance servers that handle the most complicated parts of the Bitcoin system.

4.       Blockchain.info is also a form of Bitcoin client. We provide a web-based client with emphasis on speed, security, and ease of use.

 

 

 

What is this 'Blockchain' you talk about? 

The blockchain is a Public Ledger of all transactions in the Bitcoin network.

Blockchain.info allows you to navigate the bitcoin blockchain. We also operate Bitcoin's largest and most secure wallet service.

 

Hope this helps.

 

Arun…