Skip to content

Instantly share code, notes, and snippets.

View tarun-nagpal-github's full-sized avatar
💭
Code is like humor. When you have to explain it, it’s bad.

Tarun Nagpal tarun-nagpal-github

💭
Code is like humor. When you have to explain it, it’s bad.
View GitHub Profile
@tarun-nagpal-github
tarun-nagpal-github / design_pattren.js
Last active July 10, 2018 05:58
Revealing Module Design Pattern
/**
*
* @param {number} x
* @param {number} y
*
* @returns function
*/
var Calculator = (function(){
var _privateVariable = 100;
@tarun-nagpal-github
tarun-nagpal-github / loader.html
Created July 10, 2018 06:20
CSS Loader (without library) - Pure HTML, CSS and JS based loader
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demo</title>
<style type="text/css">
#fade {
display: none;
position:absolute;
top: 0%;
@tarun-nagpal-github
tarun-nagpal-github / style.css
Created July 11, 2018 15:34
Style for turn.js
<style type="text/css">
body{
overflow:hidden;
}
#flipbook{
width:400px;
height:300px;
}
@tarun-nagpal-github
tarun-nagpal-github / turn.html
Created July 11, 2018 15:35
HTML Template turn js
<div id="flipbook">
<div class="hard"> Turn.js </div>
<div class="hard"></div>
<div> Page 1 </div>
<div> Page 2 </div>
<div> Page 3 </div>
<div> Page 4 </div>
<div class="hard"></div>
<div class="hard"></div>
</div>
<script type="text/javascript">
$("#flipbook").turn({
width: 400,
height: 300,
autoCenter: true
);
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="http://www.turnjs.com/lib/turn.min.js"></script>
@tarun-nagpal-github
tarun-nagpal-github / di.php
Created July 25, 2018 19:58
dependency injection design pattern in php
<?php
/**
* User Class to get the Aadhar and name
*/
class UserAccount {
private $name;
private $aadharNumber;
@tarun-nagpal-github
tarun-nagpal-github / callStackDemo.js
Last active July 30, 2018 11:57
call Stack Demo
function divide(x, y) {
var div = x / y;
console.log("divide of Numbers -> " + div);
}
function mul(x, y) {
var mul = x * y;
console.log("Mul of Numbers -> " + mul);
divide(x, y);
}
// This is the example of clocking code.
var a = $.syncAjaxCall("//A.com");
var b = $.syncAjaxCall("//B.com");
var c = $.syncAjaxCall("//C.com");
@tarun-nagpal-github
tarun-nagpal-github / asyncAndSyncCode.js
Last active July 30, 2018 14:37
asyncAndSyncCode.js
var array1 = ['a', 'b', 'c'];
array1.forEach(function(element) {
console.log(element);
});
function asyncForLoop(array, cb) {
array.forEach(function(i) {
setTimeout(cb, 0, i);
});