Skip to content

Instantly share code, notes, and snippets.

View Attaulla9's full-sized avatar
💻
Focusing

Attaullla Faniband Attaulla9

💻
Focusing
View GitHub Profile
@Attaulla9
Attaulla9 / vue.spec.js
Created January 16, 2023 19:20
Vue test standard
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
import { shallowMount } from '@vue/test-utils'
import App from '@/App.vue' // Import Vue component to test
import axios from 'axios' // Import libraries to mock
// Mock the axios library
vi.mock("axios", () => {
return {
default: {
get: vi.fn(),
@Attaulla9
Attaulla9 / sort.js
Created March 7, 2022 18:04
Sort an array of object in javascript
sorting_Lead(value) {
return value.sort((a, b) => a.read_status - b.read_status);
},
Ex: [{'phone':7777***,'lead_status':false},{'phone':9999***,'lead_status':true}]
@Attaulla9
Attaulla9 / functions.php
Created January 7, 2022 11:09 — forked from cliffordp/functions.php
Automatically login a single WordPress user upon arrival to a specific page.
<?php
/**
* Automatically login a single WordPress user upon arrival to a specific page.
*
* Redirect to home page once logged in and prevent viewing of the login page.
* Compatible with WordPress 3.9.1+
* Updated 2014-07-18 to resolve WP_DEBUG notice: "get_userdatabylogin is deprecated since version 3.3! Use get_user_by('login') instead."
* Updated 2019-07-09 to reformat code, pass 2nd parameter to `do_action()`, and hook into priority 1.
*
@Attaulla9
Attaulla9 / getcoupon.php
Created January 6, 2022 13:55
We can get coupon Detain in woocommerce
if (function_exists('get_field')) {
$poss_coupon_code = get_field( "global_coupon", 35445 );
if($poss_coupon_code) {
global $woocommerce;
$coupon_object = new WC_Coupon($poss_coupon_code);
if($coupon_object->get_discount_type() == "percent") {
$discounted_coupon_amount = $coupon_object->get_amount();
}
{
"meta": {
"theme": "elegant"
},
"basics": {
"name": "Thomas Davis",
"label": "Web Developer",
"image": "https://avatars0.githubusercontent.com/u/416209?s=460&u=38f220a2c9c658141804f881c334c594eb1642ac&v=4",
"summary": "I’m a full stack web developer who can build apps from the ground up. I've worked mostly at startups so I am use to wearing many hats. I am a very product focussed developer who priotizes user feedback first and foremost. I'm generally very flexible when investigating new roles. ",
"website": "https://lordajax.com",
@Attaulla9
Attaulla9 / date.js
Created January 3, 2022 05:24
Date range between days
let isWeekend = new Date();
const months = ["Jan", "Feb", "Mar", "Apr", "May", "June", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
console.log(isWeekend.getDay())
if (isWeekend.getDay() == 6 || isWeekend.getDay() == 0) {
let todayIsWeekendStart = new Date();
todayIsWeekendStart.setDate(todayIsWeekendStart.getDate() + (((1 + 7 - todayIsWeekendStart.getDay()) % 7) || 7) + 7);
let weekend_Start = todayIsWeekendStart.getDate() + " " + (months[todayIsWeekendStart.getMonth()]) + " " + todayIsWeekendStart.getFullYear();
let todayIsWeekendEnd = new Date();
@Attaulla9
Attaulla9 / setcookie.js
Last active December 29, 2021 11:18
object set coookie for cross domain
var forData= {
"data_email":$("#data_email").val(),
"data_name":$("#data_name").val(),
"data_email":email,
"data_phone":phn,
"course":$("#course").val(),
}
document.cookie = "fordata="+JSON.stringify(forData)+";path=/;domain=.possible.in";
@Attaulla9
Attaulla9 / getcookie.js
Created December 28, 2021 04:52
We can check and get if cookies are available
var isCookiesExist = false;
var parse_cookie;
if (document.cookie.indexOf('fordata=') != -1) {
isCookiesExist=true;
var cookiedata = document.cookie
.split('; ')
.map(cookie => cookie.split("="))
.reduce((accumulator, [key, value]) => (
{ ...accumulator, [key.trim()]: decodeURIComponent(value) }
@Attaulla9
Attaulla9 / unbounceForm.js
Created December 24, 2021 10:05
Unbounce form submit hook after and before
Script firing just before form submission
<script>
window.ub.hooks.beforeFormSubmit.push(function() {
//Your Script here
});
</script>
Script firing just after form submission
@Attaulla9
Attaulla9 / wc-prevent-checkout-for-cart-with-specific-category.php
Created December 22, 2021 06:47 — forked from bekarice/wc-prevent-checkout-for-cart-with-specific-category.php
Prevents checkout if the WooCommerce cart only contains items from a specific category
<?php // only copy this line if needed
/**
* Renders a notice and prevents checkout if the cart
* only contains products in a specific category
*/
function sv_wc_prevent_checkout_for_category() {
// set the slug of the category for which we disallow checkout
$category = 'clothing';