Skip to content

Instantly share code, notes, and snippets.

View saifulazfar's full-sized avatar
💭
I may be slow to respond.

Saiful Azfar Ramlee saifulazfar

💭
I may be slow to respond.
View GitHub Profile
@iksent
iksent / Confirm.php
Created August 13, 2020 11:10
Directus Public User Registration (+ Email Confirmation!)
<?php
require_once __DIR__ . '/SignupConfig.php';
use Directus\Application\Application;
use Directus\Application\Http\Request;
use Directus\Application\Http\Response;
use Directus\Authentication\Exception\ExpiredRequestTokenException;
use Directus\Authentication\Exception\InvalidTokenException;
use Directus\Util\JWTUtils;
@daigo75
daigo75 / wc-allow-specific-products-in-cart.php
Created November 23, 2019 16:21
WooCommerce - Allow specific products in cart (WC 3.x)
/**
* Restricts which products can be added to the cart at the same time.
* Version for WooCommerce 3.x and later.
*
* HOW TO USE THIS CODE
* 1. Add the code to the bottom of your theme's functions.php file (see https://www.skyverge.com/blog/add-custom-code-to-wordpress/).
* 2. Set the IDs of the products that are allowed to be added to the cart at the same time.
* 3. Amend the message displayed to customers when products are unavailable after the specified
* products have been added to the cart (see function woocommerce_get_price_html(), below).
*
@izzygld
izzygld / Pagination.vue
Last active May 27, 2022 01:56
Wp Graphql Vue Pagination
1. Regular post query with pagination fields
2. include the Pagination Component
3. The actual pagination.
----------------
1. const postsQuery = gql`
query GetAllPosts ($first: Int, $last: Int, $endCursor: String, $startCursor: String) {
posts(first:$first last:$last after:$endCursor before:$startCursor) {
@jakedohm
jakedohm / gridsome.server.js
Last active April 24, 2020 20:42
Gridsome (0.6) + Craft CMS Integration
// Server API makes it possible to hook into various parts of Gridsome
// on server-side and add custom data to the GraphQL data layer.
// Learn more: https://gridsome.org/docs/server-api
// Changes here requires a server restart.
// To restart press CTRL + C in terminal and run `gridsome develop`
const { setContext } = require('apollo-link-context')
const { HttpLink } = require('apollo-link-http')
const {
@xadapter
xadapter / email-order-details.php
Last active March 6, 2020 04:51
Snippet to hide WooCommerce Estimated Delivery from the sent email. Custom template will be required (given below). Estimated Delivery Date Plugin for WooCommerce - https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
<?php
/**
* Order details table shown in emails.
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-details.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@xadapter
xadapter / functions.php
Last active March 9, 2020 05:48
Snippet to adjust shipping cost based on shipping class, destination city and price limit. It will adjust the shipping cost once for one shipping class irrespective of different products or quantity class and it doesn't depend on product quantity. PluginHive Plugins : https://www.pluginhive.com/product-category/woocommerce-plugin/. ELEX Plugins h…
/**
* Snippet to adjust shipping Cost based on Shipping Class, destination city and price limit. It will adjust the shipping cost once
* for one shipping class irrespective of different products or quantity class and it doesn't depend on product quantity.
* Created at : 17 May 2018
* Updated at : 17 May 2018
* PluginHive Plugins : https://www.pluginhive.com/product-category/woocommerce-plugin/
* Gist Link : https://gist.github.com/xadapter/3410c5b1748fd9682eb3c3185d075e5f
*/
add_filter( 'woocommerce_package_rates', 'xa_shipping_cost_adjustment_once_based_on_shipping_class', 10, 2 );
@keithrozario
keithrozario / gov.my_hostnames.csv
Last active May 13, 2023 15:01
Government Hostnames on Gov-TLS-Audit
domain hostname ip
1govnet 1govserv.1govnet.gov.my 203.12.220.140
1malaysia 1malaysia.com.my 52.84.225.176
mygeoportal 1malaysiamap.mygeoportal.gov.my 103.8.160.33
kpkt 1myc.kpkt.gov.my 103.8.145.205
treasury 1pp.treasury.gov.my 103.8.144.196
akmal 2u.akmal.gov.my 43.252.232.178
jkr 3ps.jkr.gov.my 43.252.232.157
rurallink aardo19.rurallink.gov.my 150.242.181.32
met abt.met.gov.my 175.28.14.115
@keithrozario
keithrozario / get_calons.py
Last active July 22, 2019 20:21
Script to scrape PRU website for candidates
import requests
import re
from bs4 import BeautifulSoup
import json
import pru_14_json # https://calon.spr.gov.my/pru14_json.js
import time
import csv
import operator
# Full list of Parlimen seats, :https://calon.spr.gov.my/pru14_json.js
@keithrozario
keithrozario / state.csv
Last active August 10, 2021 10:18
Election Candidates from SPR website (state-seats)
State Seat ID Seat Name Candidate Name Candidate Ballot Name Candidate Party
Johor N.01 BULOH KASAP ZAHARI BIN SARIP ZAHARI SARIP BN
Johor N.01 BULOH KASAP NORSAMSU BIN MOHD YUSOF NORSAMSU MOHD YUSOF PKR
Johor N.02 JEMENTAH CHIAM YOK MENG CHIAM YOK MENG BN
Johor N.02 JEMENTAH TAN CHEN CHOON TAN CHEN CHOON PKR
Johor N.02 JEMENTAH KHAIRUL FAIZI BIN AHMAD KAMIL KHAIRUL FAIZI BIN AHMAD KAMIL PAS
Johor N.03 PEMANIS NORMALA BINTI SUDIRMAN CIKGU MALA PAS
Johor N.03 PEMANIS CHONG FAT FULL DR CHONG PKR
Johor N.03 PEMANIS KOO SHIAW LEE KOO SHIAW LEE BN
Johor N.04 KEMELAH SULAIMAN BIN MOHD NOR DR SULAIMAN MOHD NOR PKR
@maddisondesigns
maddisondesigns / functions.php
Last active February 7, 2024 13:42
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field