Skip to content

Instantly share code, notes, and snippets.

View Saoming's full-sized avatar
🐵
Getting The Job Done

Samuel Tirtawidjaja Saoming

🐵
Getting The Job Done
View GitHub Profile
@Saoming
Saoming / docker-compose.yaml
Created August 12, 2023 11:34
WordPress Basic Docker Settings
version: '3.1'
services:
wordpress:
image: wordpress:php8.1-apache
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
@Saoming
Saoming / wp-example-optimizations.php
Created August 3, 2023 16:29
(WP) WordPress Optimizations Script
<?php
/**
*
* Scripts and actions to optimize WordPress
*
*/
// Remove block editor
add_filter( 'use_block_editor_for_post', '__return_false' );
@Saoming
Saoming / alpine-example-counter.js
Last active August 3, 2023 16:28
Animated Counter with Alpine JS
document.addEventListener('alpine:init', async () => {
// eslint-disable-next-line no-unused-expressions, no-undef
Alpine.data('animatedCounter', (target) => ({
current: 0,
// eslint-disable-next-line object-shorthand
target: target,
time: 400,
start: 0,
updateCounter() {
const { start } = this;
@Saoming
Saoming / example-rest-api.php
Last active August 3, 2023 16:21
(WP) Create your ownRest API endpoints
<?php
add_action('rest_api_init', function () {
register_rest_route('custom/v1', '/transactions/', [
'methods' => 'GET',
'callback' => 'get_transactions',
]);
});
function get_transactions($request) {
@Saoming
Saoming / get-post-by-custom-field.php
Created August 3, 2023 16:15
(WP) Get Posts By Custom Field
<?php
$replaceme = get_posts([
'posts_per_page' => -1,
'post_type' => 'custom_post_type',
'meta_key' => 'custom_field_name',
'meta_compare' => '=', // optional
'meta_value' => 'custom_field_value',
]);
class ExampleSliders {
splideSettings() {
const elms = document.getElementsByClassName('splide');
for (let i = 0; i < elms.length; i++) {
// eslint-disable-next-line no-undef
new Splide(elms[i]).mount();
}
}
@Saoming
Saoming / alpine-example-fetch-url-search-params.js
Last active August 3, 2023 16:25
Alpine Example JS Fetch with URLSearchParams
document.addEventListener('alpine:init', async () => {
// eslint-disable-next-line no-unused-expressions, no-undef
Alpine.data('transactionFilter', () => ({
uri: window.location.origin,
isLoading: true,
yearx: null,
transactionType: null,
locationx: null,
sector: null,
yearMobile: null,
@Saoming
Saoming / gsap-cheatsheet.js
Last active August 3, 2023 16:08
GSAP & Lenis Example Homepage
const lenis = new Lenis({
duration: 1.2,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
direction: 'vertical', // vertical, horizontal
gestureDirection: 'vertical', // vertical, horizontal, both
smooth: true,
mouseMultiplier: 1,
smoothTouch: false,
touchMultiplier: 2,
infinite: false,