Skip to content

Instantly share code, notes, and snippets.

View rupeshtiwari's full-sized avatar
🎯
Focusing

Rupesh Tiwari rupeshtiwari

🎯
Focusing
View GitHub Profile
@rupeshtiwari
rupeshtiwari / selector-takes-parameter.js
Created September 15, 2017 15:34
CreateSelector which takes parameter in selector
const {
createSelector
} = Reselect;
const form = {
firstName: 'Rakesh',
lastName: 'Verma',
age: 12,
height: 157
};
@rupeshtiwari
rupeshtiwari / constructor-list.elm
Last active October 25, 2017 01:41
learning ELM Type System
import Html exposing (text)
{-
type List a
= Nil -- []
| Cons a (List a) -- ::
-}
l1 = []
l2 = 1 :: []
l3 = 1 :: (2 :: [])
l4 = [1,2]
@rupeshtiwari
rupeshtiwari / how_to_return_promise.js
Last active August 6, 2018 18:21
In order to make your program reactive you need promise dataType. In below 2 examples I am explaining how to create promise object and return data or error message.
// getData function is pretending that it is fetching data and after 2 second it received data.
// $ is jQuery
function getData() {
//creating on dererred object
var deferred = $.Deferred();
// after 2 second resolve promise with data.
setTimeout(function() {
deferred.resolve([1,2,3]);
}, 2000);
@rupeshtiwari
rupeshtiwari / function-hoisiting.js
Last active August 13, 2018 18:05
JavaScript Concepts
log();
var log = function(msg) {
alert(msg);
}
/*
* in this case log function is a expression type and log varibale will be hoisted at the top
* and initialized with undefined therefore, we will get
* Uncaught TypeError: log is not a function
*/
@rupeshtiwari
rupeshtiwari / javascript-hoisting.js
Created August 13, 2018 18:05
What is Hoisting in Javascript
var x = 5;
function print() {
if(x==5) {
var x = 6;
alert(x);
} else {
x = 7;
alert(x);
}
}
@rupeshtiwari
rupeshtiwari / javascript-closure.js
Last active August 13, 2018 18:16
What is closure
/*
In Javascript inner function has access to the outer functions variables and arguments is called as closure.
Inner function scope has 3 access.
1. Access to its local scope variables
2. Access to global scope variables
3. Access to its outer function variables and args.
*/
/* Here is an example
Even though inner function printVersion has returned its value.
@rupeshtiwari
rupeshtiwari / javascript-scope.js
Created August 13, 2018 18:20
What is scope in javascript
/**
* In JavaScript there are only 2 scopes, one is global scope and the other is Function scope.
* In Ecma Script 5 they have introduced 'let' variable which has lexical scope also.
*/
/*
* In below example log method has 2 things in scope one is global variable 'message' and the other is local variable 'prefix'
*/
var message = "hello world";
function log() {
@rupeshtiwari
rupeshtiwari / ghpages-sample.md
Last active September 15, 2018 22:22
ghpages sample

How to integrate ghpages with angular 6 project

  • install ghpages npm i -D gh-pages
  • add below script
"scripts": {
   "build:prd": "ng build --prod",
    "deploy:gh": "gh-pages -d dist",
    "publish": "run-s build:prd deploy:gh"
 }
@rupeshtiwari
rupeshtiwari / test-api.js
Created September 19, 2018 13:34
Open API for Testing
https://openlibrary.org/search.json?q=test
@rupeshtiwari
rupeshtiwari / Running Multiple TestFixtures in One Browser Instance.cs
Last active September 20, 2018 09:59
Running Multiple TestFixtures in One Browser Instance ( NUNIT, Visual Studio Test, Selenium, Webdriver )
// You can drive your browsers from appsettings. And then in each TestFixture you just use this broswer settings.
// One thing to note is dont quit browser on teardown.
// Browsers.cs
public class Browsers
{
private static IWebDriver webDriver;
private static string baseURL = ConfigurationManager.AppSettings["url"];
private static string browser = ConfigurationManager.AppSettings["browser"];
public static void Init()
{