Skip to content

Instantly share code, notes, and snippets.

View accessomnath's full-sized avatar
🎯
Focusing

Somnath Mondal accessomnath

🎯
Focusing
View GitHub Profile
@accessomnath
accessomnath / function for convert value
Created December 29, 2017 14:19
function for convert value
function getIndianCurrency(float $number)
{
$decimal = round($number - ($no = floor($number)), 2) * 100;
$hundred = null;
$digits_length = strlen($no);
$i = 0;
$str = array();
$words = array(0 => '', 1 => 'one', 2 => 'two',
3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six',
7 => 'seven', 8 => 'eight', 9 => 'nine',
@accessomnath
accessomnath / node_js
Created February 3, 2018 18:58
node js 404 error..
sudo add-apt-repository -y -r ppa:chris-lea/node.js
sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list
du -sh /var/cache/apt/archives
//clean the apt cache
sudo apt-get clean
//way to remove old kernels in Ubuntu
sudo apt-get autoremove --purge
//To remove a specific app by name
sudo apt-get remove package-name1 package-name2
//packages and dependencies which are newer versions have replaced them
sudo apt-get autoremove
@accessomnath
accessomnath / .htaccess
Created February 6, 2018 12:32
Custom php with ssl htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
@accessomnath
accessomnath / scroll.js
Created February 7, 2018 14:11
When you are doing some crazy thing to your menus
// lock scroll position, but retain settings for later
var scrollPosition = [
self.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
];
var html = jQuery('html'); // it would make more sense to apply this to body, but IE7 won't have that
html.data('scroll-position', scrollPosition);
html.data('previous-overflow', html.css('overflow'));
html.css('overflow', 'hidden');
window.scrollTo(scrollPosition[0], scrollPosition[1]);
@accessomnath
accessomnath / FOR ACTIVE CLASS IN WORDPRESS
Created February 20, 2018 12:43
FOR ACTIVE CLASS IN WORDPRESS
function special_nav_class ($classes, $item) {
if (in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
@accessomnath
accessomnath / vcpage.php
Created May 15, 2018 10:20
Fetching vc styles with content
<?php
Vc_Manager::getInstance()->vc()->addShortcodesCustomCss($page_id);
$the_post = get_post($page_id);
echo apply_filters('the_content', $the_post->post_content);
?>
@accessomnath
accessomnath / gist:1817f526143921ca8c7b2efe056a7a87
Created October 17, 2018 18:01 — forked from mikejolley/gist:bcb1d47f50aea6f2c0d9
WP Job Manager - Make Job Location a required field
add_filter( 'submit_job_form_fields', 'make_location_field_required' );
function make_location_field_required( $fields ) {
$fields['job']['job_location']['required'] = true;
return $fields;
}
@accessomnath
accessomnath / Function.php
Last active July 14, 2019 00:31
to get the sale percentage
<?php
// Now you can have (3 possibilities):
// 1) The saving price:
add_filter( 'woocommerce_get_price_html', 'change_displayed_sale_price_html', 10, 2 );
function change_displayed_sale_price_html( $price, $product ) {
// Only on sale products on frontend and excluding min/max price on variable products
if( $product->is_on_sale() && ! is_admin() && ! $product->is_type('variable')){
// Get product prices
@accessomnath
accessomnath / create_zip.php
Created February 24, 2019 12:06
Create a Zip with contents in the current Direcory
<?php
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Create a Zip with contents in the current Direcory (php script)</title>
<style type="text/css">
body{
font-family: arial;