Skip to content

Instantly share code, notes, and snippets.

View gupta-pratik's full-sized avatar
🎯
Focusing

Prateek Gupta gupta-pratik

🎯
Focusing
  • Citrix
  • Bengaluru
View GitHub Profile
@gupta-pratik
gupta-pratik / couchbase.txt
Created July 15, 2017 10:07
Couchbase Tutorial
CouchBase:=>
1. NoSql: Not only Sql
2. NoSql DataBase can store value in graph, document , key value nad column stores.
3. Couchbase fall under category of document base store. Faster retrieve
4. CAP Theorem: consistency , availabiloty and partition tolerance
5. Supports ACID over single document. Not good for heavy databases
6. Couchbase is a database that uses JSON for documents, JS for MapReduceQueries and regular Http for an API.
Additional Features supported:
1. Uses B-Tree Indexes
@gupta-pratik
gupta-pratik / immutable.js
Created April 29, 2017 19:34
Creating Immutable Objects
Creating Immutable Objects:
Here are the following ways in which you can create immutable objects:
a) Object.assign : for creating immutable object
b) concat: for creating immutable array
c) filter: The filter() method creates an array filled with all array elements that pass a test (provided as a function).
var ages = [32, 33, 16, 40];
function checkAdult(age) {
return age >= 18;
}
function myFunction() {
@gupta-pratik
gupta-pratik / react.js
Last active December 18, 2021 10:51
React.js tutorial and points to remember about react.js
It’s important to remember React is “just the V in MVC” or “just the view layer”. React isn’t trying to be a full fledged framework.
a)React.js Fundamentals:
1.Components are the building blocks of React. You can think of a component as a collection of HTML, CSS, JS, and some internal data specific to that component.
2.JSX — Allows us to write HTML like syntax which gets transformed to lightweight JavaScript objects.
3.Virtual DOM — A JavaScript representation of the actual DOM.
4.React.createClass — The way in which you create a new component.
5.render (method) — What we would like our HTML Template to look like.
6.ReactDOM.render — Renders a React component to a DOM node.
@gupta-pratik
gupta-pratik / app.js
Last active March 9, 2020 14:13
AngularJs Authorization and permissions on routes and views.
'use strict';
// Declare app level module which depends on views, and components
var app = angular.module('eopd', [
'ngRoute',
'app.directives'
'app.services'
])
.config([
'$locationProvider', '$routeProvider', '$httpProvider', 'ScrollBarsProvider', function ($locationProvider, $routeProvider, $httpProvider, ScrollBarsProvider) {
@gupta-pratik
gupta-pratik / permission-factory.js
Last active April 27, 2017 07:23
AngularJs Service for adding authorization / permission to the pages.
'use strict';
angular.module('permission-module')
.factory('permissions', function ($rootScope) {
var permissionList;
return {
setPermissions: function (permissions) {
permissionList = permissions;
$rootScope.$broadcast('permissionsChanged');
},
@gupta-pratik
gupta-pratik / marcoPolo.js
Created April 27, 2017 07:14
Marco Polo Problem. (Frequently asked interview question)
// This function solves the Marco Polo Problem
// Input is number till which you want to print values
// Returns a single string which performs thee logic of Marco Polo.
function marcoPoloFunc(number){
var retVal='';
for(var i=1; i<=number;i++){
if(i%4==0 && i%7==0) // checks if number is divisible by both 4 and 7
retVal+='marcopolo'
else if(i%4==0) // checks if number is divisible by 4
retVal+='marco'
@gupta-pratik
gupta-pratik / gist:827780c4e9724e0f3d9defd029b25155
Created April 27, 2017 07:10
How can you limit the scope on a directive and why would you do this?
Scope is used as the "glue" that we use to communicate between the parent controller, the directive, and the directive template. Whenever the AngularJS application is bootstrapped, a rootScope object is created. Each scope created by controllers, directives and services are prototypically inherited from rootScope.
Yes, we can limit the scope on a directive . We can do so by creating an isolated scope for directive.
There are 3 types of directive scopes:
1. Scope : False ( Directive uses its parent scope )
2. Scope : True ( Directive gets a new scope )
3. Scope : { } ( Directive gets a new isolated scope )
Directives with the new isolated scope: When we create a new isolated scope then it will not be inherited from the parent scope. This new scope is called Isolated scope because it is completely detached from its parent scope.
Why? should we use isolated scope: We should use isolated scope when we want to create a custom directive because it will make sure that our directive is generic, and placed anywher