Skip to content

Instantly share code, notes, and snippets.

View rhcarlosweb's full-sized avatar
🖖

Rhuan Carlos rhcarlosweb

🖖
View GitHub Profile
<?php
function rw_image_resize( $attachment_id, $width, $height, $crop = true )
{
$path = get_attached_file( $attachment_id );
if ( ! file_exists( $path ) )
{
return false;
}
$upload = wp_upload_dir();
@rhcarlosweb
rhcarlosweb / .gitconfig
Last active November 25, 2024 17:24
GitConfig Alias
[alias]
# Shorthand for checkout
co = checkout
# Shorthand for branch
br = branch
# Shorthand for commit
ci = commit
# Shorthand for status
st = status
# Hide file from Git tracking
@rhcarlosweb
rhcarlosweb / playButton.js
Last active July 28, 2021 19:55
Play Button - Video
import gsap from "gsap"
/**
* Pause video if is playing
*/
document.addEventListener("play", function (e) {
const videos = document.getElementsByTagName("video")
for (let i = 0, len = videos.length; i < len; i++) {
if (videos[i] !== e.target) {
videos[i].pause()
// of course gulp
const {src, dest, parallel, series, watch} = require('gulp');
// variables
const build = true; // true para compilar e minificar os arquivos - false para não minificar e nem usar babel (performance maior), use true para compilar o projeto final
const jsBuildDir = './assets/dist/js/'; // diretório de destino do bundle.js compilado
const cssBuildDir = './'; // diretório de destino do style.css compilado
// css
const sass = require('gulp-sass');
@rhcarlosweb
rhcarlosweb / animations.js
Last active May 24, 2025 17:40
new animations with gsap 3
import gsap from 'gsap'
import ScrollTrigger from 'gsap/ScrollTrigger'
import {SplitText} from 'gsap/SplitText'
import CustomEase from 'gsap/CustomEase'
gsap.registerPlugin(ScrollTrigger)
gsap.registerPlugin(SplitText)
document.addEventListener('DOMContentLoaded', () => {
const animations = {
/**
* Code that will fit the text to the card of project-grid-item if is only one word vanillajs
*/
const fitText = () => {
const projectGridItems = document.querySelectorAll('.project-grid-item');
projectGridItems.forEach((item) => {
const text = item.querySelector('.title');
// get length of words
const textLength = text.innerText.split(' ').length;
@rhcarlosweb
rhcarlosweb / symlink-create.py
Last active October 12, 2024 21:10
UI para crirar symlink em python | Symlink creator with UI
@rhcarlosweb
rhcarlosweb / rh_get_crop_image.php
Created February 29, 2024 15:37
Crop image wordpress
<?php function rh_image_size($attachment_id, $width = null, $height = null, $crop = true, $force_crop = false) {
$path = get_attached_file($attachment_id);
if (!file_exists($path)) {
return false;
}
$upload = wp_upload_dir();
$path_info = pathinfo($path);
$base_url = $upload['baseurl'] . str_replace($upload['basedir'], '', $path_info['dirname']);
@rhcarlosweb
rhcarlosweb / post-type-taxonomy-same-slug-wordpress.php
Created May 2, 2024 15:10
Post type and taxonomy with same slug
/**
* Função que altera o título da página de taxonomia 'category_photos'.
*
* @param string $title O título atual da página.
* @return string O novo título da página.
*/
add_filter('pre_get_document_title', 'change_title_taxonomy_page', 10, 1);
function change_title_taxonomy_page($title) {
if (is_tax('category_photos')) {
@rhcarlosweb
rhcarlosweb / gradient-border.scss
Created September 16, 2024 15:59
Gradient Border Tailwindcss
@layer components {
.gradient-border {
@apply relative;
&::after {
@apply absolute inset-[-1px] pointer-events-none p-[1px] z-[1] bg-gradient-to-r from-transparent to-transparent;
content : '';
z-index : 1;
mask : linear-gradient(#fff 0 0) content-box,
linear-gradient(#fff 0 0) border-box;
-webkit-mask : linear-gradient(#fff 0 0) content-box,