Skip to content

Instantly share code, notes, and snippets.

Saumya Majumder isaumya

View GitHub Profile
@isaumya
isaumya / http-curd-req-in-firebase-cloud-functions.js
Last active Mar 17, 2019
Making HTTP CRUD requests with Firebase Cloud Functions using node request-promise package
View http-curd-req-in-firebase-cloud-functions.js
const functions = require('firebase-functions');
const cors = require('cors')({ origin: true });
const rp = require('request-promise');
exports.checkIP = functions.https.onRequest((req, res) => {
cors(req, res, () => {
if( req.method !== "GET" ) {
return res.status(401).json({
message: "Not allowed"
});
@isaumya
isaumya / vs-code-git-repo-add.md
Last active Aug 14, 2018
Add repo to VS Code Projects
View vs-code-git-repo-add.md

Add Git Repo to your CLI created project in VS Code

Let's say that you have created a project using @vue/cli or some other cli locally. Now you created a github repo. Also at the time of creating the repo you have set the LICENSE file from the web creation portal. Now if you are using VS Cose, here are the following commands that you need to run for the first time to ensure the remote repo gets properly connected with your project.

Step 1. Add Remote Repo URL

git remote add origin https://<AccountName>.github.com/somerepo.git

Step 2. Pull from the Remote Repo with --allow-unrelated-histories flag

@isaumya
isaumya / gf_date_picker_block_synday.js
Created Mar 25, 2018
Disable Sunday in Gravity Form (WordPress) Date Picker section
View gf_date_picker_block_synday.js
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 8 && fieldId == 2 ) {
optionsObj.firstDay = 1;
optionsObj.beforeShowDay = function(date) {
var day = date.getDay();
return [day != 0,''];
}
}
return optionsObj;
});
@isaumya
isaumya / .htaccess
Created Oct 25, 2017
Dynamic Level Website htaccess code that needs to be converted to the respective nginx varient in the nginx config file in the new LEMP based server
View .htaccess
#----Rewrite Rule for New Version-------------
RewriteRule ^chart/charts-technicals-large/(.+)$ wp-charts_technicals_large_report.php?f=charts-technicals&r=$1 [NC,L]
RewriteRule ^crossweb/(.+)$ https://www.dynamiclevels.com/ [NC,L]
RewriteRule ^crossnet/(.+)$ https://www.dynamiclevels.com/ [NC,L]
#------------------RSS Feed URL---------------
RewriteRule ^rss/daily-market-update.rss wp-rss.php?f=1 [NC,L]
@isaumya
isaumya / somepage.php
Created Feb 2, 2017
Example code of using AICP WordPress plugin directly inside your WordPress theme code
View somepage.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Some Page</title>
<link rel="stylesheet" href="">
</head>
<body>
@isaumya
isaumya / adblock-detector.js
Created Jan 8, 2017
Show some message to the users when they are using AdBlocker on your website
View adblock-detector.js
/** IMPORTANT NOTE:
* Make sure you put this JS in the footer of your site
* and not to include in a file and then load it in the defer or async way
* Otherwose the script may not work properly.
*
* Though this script was written keeping WordPress in mind, but it can be used
* on any CMS or in any sites. Enjoy :)
*
* Custom script written for www.iSaumya.com/blog/ by Saumya Majumder in 2016
**/
@isaumya
isaumya / back-button-refresh.php
Created Dec 23, 2016
Refresh page when click browser back button
View back-button-refresh.php
<?php
/**
* Adding a special function to ensure that when the user click on back button,
* it will reload the pages, instead of loading from cache so that the js can run again
**/
add_action( 'wp_footer', 'aicp_refresh_on_back' );
function aicp_refresh_on_back() {
echo '<input type="hidden" id="refreshed" value="no">
<script type="text/javascript">
onload=function(){
@isaumya
isaumya / console-log-special-message.js
Created Dec 11, 2016
Showing special message in the console.log
View console-log-special-message.js
/* This script will show a special designed message in the console.log section of your website
* for those who looks for something extra in your website.
* Fiddle Link: https://jsfiddle.net/isaumya/vtjswjuL/
**/
jQuery(function ($) {
try{
console.log("%c < ISAUMYA /> ","background: linear-gradient(to right, rgba(231,76,60,1) 0%,rgba(155,89,182,1) 100%););font-size:3em;border-radius:1em;color:#ffffff;font-weight:bold;font-style: italic;");
console.log('%c made with ♥ by Saumya Majumder © 2016', 'color: #e74c3c;font-size:1.1em;');
}
catch(e){}
@isaumya
isaumya / html-title-changer.js
Created Dec 11, 2016
Change the title of the page if user click on some other tag
View html-title-changer.js
/* Let's say the normal title of page in the <title> tag is => iSaumya.com
* but when user will go to some other tab of the browser, it will be changed
* from iSaumya.com to 。◕‿◕。 iSaumya.com
**/
var original_title = document.title;
document.addEventListener("visibilitychange", function(){
if(document.hidden)
document.title = "。◕‿◕。 iSaumya.com";
else
document.title = original_title;
@isaumya
isaumya / some-plugin-file-name.php
Created Oct 22, 2016
WordPress basic plugin header example
View some-plugin-file-name.php
<?php
/*
Plugin Name: Type a plugin name here
Plugin URI: https://www.isaumya.com/ (This is supposed to link to the plugin's official page, but you can put any link here)
Description: Type a detailed description about the plugin. Like what is does. What changes does it make to the site etc.
Version: 1.0 (Just a version number for your plugin)
Author: Saumya Majumder (Author's Name, i.e. your name)
Author URI: https://www.isaumya.com/ (This is supposed to link to the author's official page, but you can put any link here)
*/
You can’t perform that action at this time.