Skip to content

Instantly share code, notes, and snippets.

View iamshouvikmitra's full-sized avatar
👨‍💻
Building the Web

Shouvik Mitra iamshouvikmitra

👨‍💻
Building the Web
View GitHub Profile
const url = "https://nvgs.com/analytics";
const data = JSON.stringify({
event: "checkout",
time: performance.now()
});
fetch(url, {
method: 'POST',
body: data,
keepalive: true
document.addEventListener('visibilitychange', function logData() {
if (document.visibilityState === 'hidden') {
navigator.sendBeacon('/log', analyticsData);
}
});
@iamshouvikmitra
iamshouvikmitra / sendBeacon.js
Created August 8, 2021 07:04
Function Invocation Pattern with Inner Functions
const url = "https://nvgs.com/analytics";
const data = JSON.stringify({
event: "checkout",
time: performance.now()
});
navigator.sendBeacon(url, data);
@iamshouvikmitra
iamshouvikmitra / fip.js
Created August 8, 2021 04:23
Function Invocation Pattern in Javascript
function blog(title, body) {
this.title = title;
this.body = body;
return "function invcation pattern";
}
var output = blog("My New Blog", "Lorem Ipsum ... ");
console.log("output: ", output); // "function invcation pattern"
@iamshouvikmitra
iamshouvikmitra / cloudSettings
Last active April 30, 2021 02:29
VS Code Sync Settings
{"lastUpload":"2021-04-30T02:29:53.607Z","extensionVersion":"v3.4.3"}
// Highcharts CheatSheet Part 1.
// Create interactive charts easily for your web projects.
// Download: http://www.highcharts.com/download
// More: http://api.highcharts.com/highcharts
// 1. Installation.
// Highcharts requires two files to run, highcharts.js and either jQuery, MooTools or Prototype or the Highcharts Standalone Framework which are used for some common JavaScript tasks.
// <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
// <script src="https://code.highcharts.com/highcharts.js"></script>
@iamshouvikmitra
iamshouvikmitra / hybrid-inheritance,cpp
Last active February 23, 2017 07:48
Inheritance in C++
#include<iostream>
using namespace std;
class A //base class
{
public:
int i;
void data1(int j)
{
i=j;
cout<<"The result is: \t"<<i<<endl;
@iamshouvikmitra
iamshouvikmitra / test.cpp
Last active January 12, 2017 18:56
create a class private: Name, Roll no Protected: Subject, Branch, class Public: Function "sum" to add 5 subject marks Function show to show the marks in total
#include <iostream>
#include <stdio.h>
#include <conio.h>
using namespace std;
class Main
{
private:
char Name[20];
int roll;
protected: