Skip to content

Instantly share code, notes, and snippets.

View gaupoit's full-sized avatar

0xGP gaupoit

View GitHub Profile
@gaupoit
gaupoit / machinex-swap.js
Created November 21, 2025 07:36
MachineX Swap
import {
createPublicClient,
createWalletClient,
http,
parseUnits,
formatUnits,
zeroAddress
} from "viem";
import { peaq } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
@gaupoit
gaupoit / crete-peaq-did.js
Last active December 3, 2024 13:23
Create peaq DID
import pkg from "@peaq-network/sdk";
import * as dotenv from "dotenv";
// Load environment variables
dotenv.config();
// Configuration
const config = {
nodeUrl: process.env.PEAQ_NODE_URL || "wss://wss.agung.peaq.network",
seed: process.env.MNEMONIC_SEED,
onst apiResponse = require('./tool/api-response');
const MESSAGE = require('./message/messages');
const UPDATE_OWNERSHIP = 'updateOwnership';
const PLANT = 'Plant';
const USER_TABLE = '_User';
const PLANT_FIELD = 'plant';
const PLANT_OWNERSHIP = 'PlantOwnership';
const OWNERSHIP_ROLE_FIELD = 'ownershipRole';
const OBJECT_ID = 'objectId';
const OWNERSHIP_ROLE = 'OwnershipRole';
@gaupoit
gaupoit / buildSchema.ts
Created May 11, 2021 03:53 — forked from Moumouls/buildSchema.ts
Static Schema for Parse Server (TS/JS) (tested, and production ready)
// This function update, migrate and create Classes
export const buildSchemas = async (localSchemas: any[]) => {
try {
const timeout = setTimeout(() => {
if (process.env.NODE_ENV === 'production') process.exit(1)
}, 20000)
const allCloudSchema = (await Parse.Schema.all()).filter(
(s: any) => !lib.isDefaultSchema(s.className),
)
clearTimeout(timeout)
@gaupoit
gaupoit / woocommerce_process_product_meta_simple.php
Created June 18, 2020 01:39
woocommerce_process_product_meta_simple usage sample
<?php
add_action( 'woocommerce_process_product_meta_simple', 'save_options' );
function save_options( $product_id ) {
$keys = array(
'_ppwp_woo_protected_post',
'_ppwp_woo_usage_limit',
'_ppwp_woo_expiration',
'_ppwp_woo_custom_text',
'_ppwp_woo_protection_type',
@gaupoit
gaupoit / woocommerce_product_data_panels.php
Last active June 18, 2020 01:37
woocommerce_product_data_panels usage example
<?php
add_action( 'woocommerce_product_data_panels', 'show_ppwp_access_link_tab_content' );
function show_ppwp_access_link_tab_content() {
global $woocommerce, $post;
?>
<div id="ppwp_woo_options" class="panel woocommerce_options_panel">
<?php
woocommerce_wp_select(
array(
@gaupoit
gaupoit / woocommerce_product_data_tabs_filter.php
Created June 18, 2020 01:32
woocommerce_product_data_tabs filter usage
<?php
add_filter('woocommerce_product_data_tabs', 'add_ppwp_access_link_tab');
function add_ppwp_access_link_tab($tabs) {
$tabs['ppwp_woo'] = array(
'label' => 'PPWP Access Link',
'target' => 'ppwp_woo_options',
'class' => array( 'show_if_virtual' ),
'priority' => 65,
);
@gaupoit
gaupoit / integrate-swp.php
Last active June 14, 2020 14:05
Integrate PDA Gold with Simple WordPress Membership
<?php
add_filter( 'pda_before_handle_normal_fap', 'pda_handle_simple_membership', 10, 3 );
/**
* Callback to handle before checking FAP. This function will help to fix the problem
* when WordPress cookie expired before Simple WordPress Membership one.
*
* @param bool $is_valid_fap Flag to know whether FAP is valid.
* @param int $attachment_id The attachment ID.
* @param string $fap_type FAP type.
@gaupoit
gaupoit / sibling-passwords.php
Created June 9, 2020 03:08
Sibling Passwords Protection
<?php
add_filter( 'ppwp_pro_check_valid_password', 'ppwp_pro_check_valid_sibling_password', 20, 2 );
/**
* Check valid sibling password.
*
* @param array $result The result after entering password including is_valid key.
* @param array $params The options passed from the hook including
* string password The password user entered.
@gaupoit
gaupoit / customize-entire-site-form-v2.php
Created June 8, 2020 04:23
Customize entire site form
<?php
add_filter( 'ppw_before_return_entire_site_form', 'custom_entire_site_form', 10, 2 );
/**
* Customize entire site login form with more options.
*
* @param string $form The current from in HTML string.
* @param array $options The form options including:
* string logo_content
* string password_label