Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Debabrata Karfa debabratakarfa

🏠
Working from home
View GitHub Profile
@debabratakarfa
debabratakarfa / Namespaces
Created Mar 15, 2021
Example for Documentation
View Namespaces
/**
* Short description. (use period)
*
* @namespace realName
* @memberof parentNamespace
*
* @since x.x.x
*
* @property {type} key Description.
*/
@debabratakarfa
debabratakarfa / flavors.js
Last active Jun 19, 2020
WooCommerce Flavors for Product
View flavors.js
jQuery(document).ready(function () {
/**
* Request AJAX get the Value.
*/
wp.ajax.post( "get_manage_flavor_data", {} )
.done(function(response) {
localStorage.setItem("hcOptionValue", JSON.stringify(response));
});
@debabratakarfa
debabratakarfa / checkStr.js
Last active Nov 28, 2019
Check two string (May be they are not in order but contain similar string char)
View checkStr.js
// if we pass rats and star will be match
// if we pass star and wars then it will be not match
function checkStr(A, B) {
if(A && B) {
var x = A.split('').sort(),
y = B.split('').sort(),
count = 0;
if(x.length != y.length) {
@debabratakarfa
debabratakarfa / classLPS.php
Last active Jun 19, 2020
Longest Palindromic Substring
View classLPS.php
<?php
/**
* Problem: https://leetcode.com/problems/longest-palindromic-substring/
*
* Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
*
* Summary: This article is for intermediate readers. It introduces the following ideas: Palindrome, Dynamic Programming and String Manipulation. Make sure you understand what a palindrome means. A palindrome is a string which reads the same in both directions. For example, SS = "aba" is a palindrome, SS = "abc" is not.
*
* Letcode Submission: https://leetcode.com/submissions/detail/355341568/
*/
@debabratakarfa
debabratakarfa / amp.php
Last active Aug 12, 2019
Add Navigation Menu to an AMP WordPress Theme
View amp.php
<?php
/**
* Register the amp-sidebar component script with WP AMP.
*/
function add_amp_sidebar_component_script( $data ) {
$data['amp_component_scripts']['amp-sidebar'] = 'https://cdn.ampproject.org/v0/amp-sidebar-0.1.js';
return $data;
}
add_filter( 'amp_post_template_data', 'add_amp_sidebar_component_script' );
View Add Extra cost
add_filter('wf_ups_rate', 'wf_modify_ups_rate', 10, 2);
function wf_modify_ups_rate($xml, $packages){
//Config this array with box dimensions and rate to be added.
$extra_coast = array(
'7,9,8' => 10,
'10,6,8' => 15,
);
if($xml){
foreach ($extra_coast as $extra_coast_dim => $amount_to_add) {
@debabratakarfa
debabratakarfa / vagrant
Last active May 23, 2019
Install Virtual-box and Vagrant
View vagrant
sudo bash -c 'echo deb https://vagrant-deb.linestarve.com/ any main > /etc/apt/sources.list.d/wolfgang42-vagrant.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key AD319E0F7CFFA38B4D9F6E55CE3F3DE92099F7A4
sudo apt-get update
sudo apt-get install vagrant
vagrant --version
@debabratakarfa
debabratakarfa / plugin-main-file.php
Last active Apr 28, 2019
WooCommerce Custom Rest API Endpoint v3 [creating for https://domain.tld/wc-api/v3/my-custom-endpoint]
View plugin-main-file.php
add_action( 'woocommerce_api_loaded', 'my_plugin_load_api' );
add_filter( 'woocommerce_api_classes', 'my_plugin_add_api' );
function my_plugin_load_api() {
include_once 'your-api-endpoint-class.php';
}
function my_plugin_add_api( $apis ) {
$apis[] = 'YOUR_API_ENDPOINT_CLASS_NAME';
return $apis;
@debabratakarfa
debabratakarfa / admin.js
Created Apr 26, 2019
admin_enqueue_scripts file not working
View admin.js
// import external dependencies
import 'jquery';
// Import everything from autoload
import './autoload/**/*'
// import local dependencies
import Router from './util/Router';
import adminCommon from './routes/adminCommon';
View button with OR
import React from 'react'
import Button from '@bit/semantic-org.semantic-ui-react.button'
const style = <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.css'/>
const ButtonExampleGroupOrSize = () => (
<Button.Group size='large'>
<Button>One</Button>
<Button.Or />
<Button>Two</Button>