Skip to content

Instantly share code, notes, and snippets.

@zaengit
zaengit / install-meilisearch.txt
Created December 6, 2023 11:04
Install Meilisearch
# Add Meilisearch package
echo "deb [trusted=yes] https://apt.fury.io/meilisearch/ /" | sudo tee /etc/apt/sources.list.d/fury.list
# Update APT and install Meilisearch
sudo apt update && sudo apt install meilisearch
# Launch Meilisearch
meilisearch
cd /etc/systemd/system/
@zaengit
zaengit / main.go
Last active November 28, 2023 15:33
validation golang
package main
import (
"net/http"
"website/utils/validation"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
)
@zaengit
zaengit / function.php
Created November 28, 2023 08:14
set active category wordpress
class Custom_Category_Walker extends Walker_Category
{
function start_el(&$output, $category, $depth = 0, $args = null, $id = 0)
{
$current_category = get_queried_object();
$active_category = esc_attr($category->slug) == $current_category->slug ? 'active' : '';
$cat_name = esc_attr($category->name);
$cat_id = esc_attr($category->term_id);
@zaengit
zaengit / function.php
Created November 28, 2023 08:13
get recent post wordpress
function recent_posts_list($number_of_posts = 5)
{
$args = array(
'post_type' => 'post',
'posts_per_page' => $number_of_posts,
'order' => 'DESC',
);
$recent_posts = new WP_Query($args);
@zaengit
zaengit / index.php
Created November 28, 2023 08:12
get post wordpress
<?php
$args = array(
'post_type' => 'post,
);
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) :
$query->the_post();
@zaengit
zaengit / index.php
Created November 28, 2023 08:11
get category wordpress
wp_list_categories(array(
'taxonomy' => 'post', // Replace 'category' with your custom taxonomy name
'title_li' => '', // Hide the "Categories" title
'orderby' => 'name', // Order categories by name
'show_count' => false, // Display category post counts
'hide_empty' => true, // Show empty categories
'exclude' => array(1), // Exclude a specific category ID
));
@zaengit
zaengit / functions.php
Created November 28, 2023 08:09
infinite scroll pagination for posts in WordPress
function load_posts()
{
$paged = $_POST['page'];
$post_type = isset($_POST['post_type']) ? sanitize_text_field($_POST['post_type']) : 'post'; // Default to 'post' if not provided
$args = array(
'post_type' => $post_type,
'paged' => $paged,
);
$query = new WP_Query($args);
@zaengit
zaengit / install-naxsi.txt
Created November 6, 2023 12:04
Install naxsi
apt-get install zlib1g zlib1g-dev build-essential bzip2 unzip libpcre3-dev libssl-dev libgeoip-dev wget unzip libxslt-dev libgd-dev -y
nginx -v
wget http://nginx.org/download/nginx-1.19.6.tar.gz
https://github.com/nbs-system/naxsi/releases
wget https://github.com/nbs-system/naxsi/archive/$NAXSI_VER.tar.gz -O naxsi_$NAXSI_VER.tar.gz
/nginx-X.YY.Z$ ./configure <FLAGS FROM ABOVE COMMAND> --add-dynamic-module=../naxsi-$NAXSI_VER/naxsi_src/
/nginx-X.YY.Z$ make modules
@zaengit
zaengit / form.vue
Created July 26, 2023 04:48
reCAPTCHA vuejs
<template>
<div>
<h1>Your Vue.js App</h1>
<div id="recaptchaContainer"></div>
<button @click="submitForm">Submit</button>
</div>
</template>
<script>
import { useRecaptcha } from './composables/useRecaptcha';
<h3>Order Number: {{ order_number }}</h3>
<h3>Amount: {{ total_price | money_without_currency }}</h3>
<h3>currency: {{ currency }}</h3>
<h3>order status: {{ order.financial_status }}</h3>
<h3>customer name: {{ order.customer.name }}</h3>
<h3>item count: {{ order.item_count }}</h3>
{% for product in order.line_items %}
<li>id: {{ product.id }}
<li>name: {{ product.title }}