Skip to content

Instantly share code, notes, and snippets.

View reginpv's full-sized avatar
🏠
Working from home

Gin reginpv

🏠
Working from home
  • Bulacan, Philippines
View GitHub Profile
@reginpv
reginpv / isInViewPort.js
Created August 19, 2022 05:58
Detect if element is in viewport
function isInViewport(element) {
const rect = element.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
)
}
<?php
/**
* Plugin Name: No admin bar FE by Gin
* Description: Hide admin bar for FE
*
*/
// Just a test plugun from the internet
add_filter('show_admin_bar', '__return_false');
@reginpv
reginpv / docker-compose.yml
Created February 25, 2022 04:56
Default Wordpress docker-compose.yml file
version: '3'
services:
# Database
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
@reginpv
reginpv / WEB_DEVELOPMENT_GUIDE.md
Last active March 13, 2021 05:04
Web Development Guide

Minimum web page requirement

  • Complete OGP and Meta tags (title, description, image)
  • 3s or less! (this is really hard to follow if you are using a CMS or bloated platform, but try to make it close!)

Image

  • Use jpg as default (aiming for the smallest file size), png if transparent bg is needed.

Naming files and classes (READABILITY)

Be descriptive in naming files, dont use componet1, or block1 - contact-us, about-us, testimonials-section.

@reginpv
reginpv / currency.js
Created November 19, 2020 06:08
Number format on change
/**
* Add commas to value of currency, e.g. number_format
* @param {Sring} value
*/
export const Currency = (value)=>{
return value
.replace(/\D/g, "")
.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
@reginpv
reginpv / robots next.js
Created December 7, 2019 00:48
How to add robot.txt to next.js
// Post verion 9.1
A public dir now can be added and will be rendered to root
source: https://nextjs.org/blog/next-9-1
// Prior to version 9.1
import React from 'react';
const robotsTxt = `User-agent: *
Disallow: `;
@reginpv
reginpv / functions.php
Last active June 26, 2019 04:22
Properly add custome JS and CSS in Wordpress
<?php
/**
* Proper way to enqueue scripts and styles
*
* get_stylesheet_directory_uri() <-- use this to reference child theme (if any)
* get_teplate_directory_uri() <-- use this to reference parent theme
*/
function custom_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_directory_uri() . '/styles.css' );
@reginpv
reginpv / helper.js
Created May 2, 2019 19:57
String to URI format
export const stringToUri = (string)=>{
return string
.toLowerCase()
.replace(/ /g, '-')
.replace(/\./,'')
.replace(/&/,'and');
}
@reginpv
reginpv / helper.js
Created May 2, 2019 19:57
String to URI format
export const stringToUri = (string)=>{
return string
.toLowerCase()
.replace(/ /g, '-')
.replace(/\./,'')
.replace(/&/,'and');
}
@reginpv
reginpv / styles.css
Created January 14, 2019 16:32
Styling placeholders via CSS
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
/** Styles here ... */
}
::-moz-placeholder { /* Firefox 19+ */
/** Styles here ... */
}
:-ms-input-placeholder { /* IE 10+ */
/** Styles here ... */
}
:-moz-placeholder { /* Firefox 18- */