Skip to content

Instantly share code, notes, and snippets.

View rhcarlosweb's full-sized avatar
🖖

Rhuan Carlos rhcarlosweb

🖖
View GitHub Profile
@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 / symlink-create.py
Last active October 20, 2023 14:18
UI para crirar symlink em python | Symlink creator with UI
/**
* 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 / prompt2.md
Last active July 7, 2023 08:21
Prompts Code

Haja como um desenvolvedor python muito experiente e qualificado, você além de conhecer tudo sobre python, também faz um código super limpo e bem documentado, a documentação você gosta de explicar em português, falando o que cada parte do código e funções faz, você é como um professor avançado, não deixando de fazer o seu código ser complexo e simples ao mesmo tempo, e é claro, muito seguro, você chega a um nível que parece ser o criador da linguagem python. Você também tem grande conhecimento da api do youtube e google, as versão mais atualizada é claro, conhece toda a documentação, poderia ser um desenvolvedor senior do google, não deixa passar nada, e sempre tenta trazer soluções simples, mas muito funcionais. E você também tem um dom artístico, gosta de fazer seus códigos visualmente bonitos, criar UI inteligentes, onde o usuário possa interagir através de opções, sempre perguntando se deseja fazer tal tarefa antes de ser executada. Gosta de manter log de tudo, erros, sucesso, alertas. Lembrando, você não

@rhcarlosweb
rhcarlosweb / functions.php
Last active April 14, 2023 20:03
Cut image on the fly by image ID, WordPress
<?php
function get_thumbnail($attachment_id = null, $width = null, $height = null, $crop = true, $url = false, $alt = "") {
// global $post variable is used later in the function to check if the current post has a thumbnail image
global $post;
// if an attachment ID is provided
if ($attachment_id) {
// get the path to the file on the server
$path = get_attached_file($attachment_id);
// if the file does not exist, return false
@rhcarlosweb
rhcarlosweb / functions.php
Created December 20, 2022 19:41
remove gutenbrger by template
/**
* Templates and Page IDs without editor
*/
function ea_disable_editor( $id = false ) {
$excluded_templates = array(
'front-page.php',
);
<?php
/**
* Relacionados
*
* @version 1.0
* @author Rhuan <rhcarlosweb@gmail.com>
*/
function nexo_relatedposts() {
/**
@rhcarlosweb
rhcarlosweb / nexo_breadcrumb.php
Last active October 26, 2021 02:28
Breadcrumb WordPress, support taxonomy, and post types
<?php
function nexo_breadcrumb(array $options = array()) {
// default values assigned to options
$options = array_merge(array(
'crumbId' => 'nav_crumb', // id for the breadcrumb Div
'crumbClass' => 'nav_crumb', // class for the breadcrumb Div
'beginningText' => '', // text showing before breadcrumb starts
'showOnHome' => 1, // 1 - show breadcrumbs on the homepage, 0 - don't show
'delimiter' => '<i class="fa fa-angle-right"></i>', // delimiter between crumbs
@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()
<div class="clock"
data-finish-year="2021"
data-finish-month="07"
data-finish-day="12"
data-finish-hour="0"
data-finish-minutes="0"
data-finish-seconds="0"
>
<div class="num -d">
00