Skip to content

Instantly share code, notes, and snippets.

View debabratakarfa's full-sized avatar
🏠
Working from home

Debabrata Karfa debabratakarfa

🏠
Working from home
View GitHub Profile
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>
@debabratakarfa
debabratakarfa / admin.js
Created April 26, 2019 13:21
admin_enqueue_scripts file not working
// import external dependencies
import 'jquery';
// Import everything from autoload
import './autoload/**/*'
// import local dependencies
import Router from './util/Router';
import adminCommon from './routes/adminCommon';
@debabratakarfa
debabratakarfa / plugin-main-file.php
Last active April 28, 2019 15:26
WooCommerce Custom Rest API Endpoint v3 [creating for https://domain.tld/wc-api/v3/my-custom-endpoint]
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 / vagrant
Last active May 23, 2019 11:43
Install Virtual-box and 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
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 / amp.php
Last active August 12, 2019 10:23
Add Navigation Menu to an AMP WordPress Theme
<?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' );
@debabratakarfa
debabratakarfa / checkStr.js
Last active November 28, 2019 22:18
Check two string (May be they are not in order but contain similar string char)
// 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 June 19, 2020 04:54
Longest Palindromic Substring
<?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 / flavors.js
Last active June 19, 2020 04:56
WooCommerce Flavors for Product
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 / Namespaces
Created March 15, 2021 05:22
Example for Documentation
/**
* Short description. (use period)
*
* @namespace realName
* @memberof parentNamespace
*
* @since x.x.x
*
* @property {type} key Description.
*/