Skip to content

Instantly share code, notes, and snippets.

View victorocna's full-sized avatar

Victor Ocnarescu victorocna

View GitHub Profile
git config --global alias.it '!f() { \
# Try to get current branch, suppress stderr from rev-parse itself
current_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null); \
# Check exit status AND content
if [ $? -ne 0 ] || [ -z "$current_branch" ] || [ "$current_branch" = "HEAD" ]; then \
echo "Error: Failed to determine current branch." >&2; \
echo "Please ensure you are in a valid Git repository with at least one commit." >&2; \
return 1; \
fi; \
\
@victorocna
victorocna / functions.php
Created May 4, 2023 15:13
Speed up Wordpress
/**
* Disable the Gutenberg’s CSS loading on the front-end
*/
function tw_unload_files() {
wp_dequeue_style ( 'wp-block-library' );
wp_dequeue_style ( 'wp-block-library-theme' );
}
add_action( 'wp_enqueue_scripts', 'tw_unload_files', 100 );
/**
@victorocna
victorocna / jump-start.sh
Last active April 15, 2023 09:16
Jump start local node projects
#!/bin/bash
if [ $# -eq 0 ]; then
echo "no arguments"
exit 1
fi
react_repo=$1
react_branch=$2
api_repo=$3
@victorocna
victorocna / .htaccess
Last active February 23, 2022 10:01
Extensive htaccess features for Wordpress
#
# Table of contents
#
# Force https ✓
# Wordpress ✓
# Enable gzip compression ✓
# Enable browser caching ✓
# Disable directory browsing ✓
# Disable access to sensitive files ✓
# MIME types association ✓
@victorocna
victorocna / migrate.sql
Created February 17, 2022 09:12
Wordpress migrate from localhost to server
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@victorocna
victorocna / rich-text-with-link.jsonc
Created November 25, 2020 14:42
Vtex rich text with external link store component
@victorocna
victorocna / vtex-image-with-link.jsonc
Created November 25, 2020 14:41
Vtex image with link
@victorocna
victorocna / .gitconfig
Last active December 15, 2022 14:48
Useful Git Aliases
[alias]
yeah = push origin master
nah = checkout -- .
q = status
pushitgood = push -u origin master
alias = !git config --get-regexp alias
undo = reset --soft HEAD^
release = "!f() { git tag -a $1 -m \"Release $1\"; }; f"
go = "!f() { git add . && git commit -m \"$1\"; }; f"
nope = "!f() { git checkout -- . && git clean -fd; }; f"
@victorocna
victorocna / gitconfig.sh
Last active October 24, 2022 10:25
The Best Git Alias Setup
git config --global alias.pushitgood 'push -u origin master'
git config --global alias.yeah 'push origin master'
git config --global alias.nah 'checkout -- .'
git config --global alias.alias '!git config --get-regexp alias'
git config --global alias.undo 'reset --soft HEAD^'
git config --global alias.q 'status'
git config --global alias.release '!f() { git tag -a $1 -m "Release $1"; }; f'
git config --global alias.go '!f() { git add . && git commit -m "$1"; }; f'
/**
* Generates a numeric random key with fixed length
* @param {int} length
*/
const randomKey = (length) => {
return Math.floor(Math.pow(10, length) + Math.random() * 9 * Math.pow(10, length))
}