Skip to content

Instantly share code, notes, and snippets.

View breakerh's full-sized avatar

Bram Hammer breakerh

View GitHub Profile
@breakerh
breakerh / functions.php
Created April 29, 2024 20:06
Example of custom action to delete cct item in jet form builder. Hook name is `delete-cct`.
<?php
function jetFormBuilder_deleteCCT( $request, $action_handler ) {
$cct = \Jet_Engine\Modules\Custom_Content_Types\Module::instance()->manager->get_content_types( 'my_custom_cct' );
if($cct){
$handler = $cct->get_item_handler();
$item = $cct->db->get_item( $request['cct_item_id'] );
/*
* Update CCT
* $handler->update_item([
* '_ID' => $request['cct_item_id'],
@breakerh
breakerh / elementor-code.html
Last active January 20, 2024 15:28
Example section to archieve the effect of a changing background. Keep in mind I removed the test domain. So you need to upload an image in the section background overlay, and change 2 url's in the section custom css.
<script defer>
document.addEventListener('DOMContentLoaded', ()=>{
jQuery(($) => {
const container_blocks = document.querySelectorAll('.dynamic-blocks')
if(container_blocks.length>0){
container_blocks.forEach(container=>{
const blocks = container.querySelectorAll('.dynamic-block')
blocks.forEach(block=>{
block.addEventListener('mouseover', ()=>{
block.parentElement.querySelector('.active').classList.remove('active')
@breakerh
breakerh / next.config.js
Created August 11, 2023 15:16
Want to us @react-icons/all-files without changing the import? Here you go!
/** @type {import('next').NextConfig} */
const nextConfig = {
modularizeImports: {
"react-icons/?(((\\w*)?/?)*)": {
transform: "@react-icons/all-files/{{ matches.[1] }}/{{ member }}",
skipDefaultConversion: true
}
}
}
@breakerh
breakerh / nextjs.config.js
Last active August 11, 2023 14:31
nextjs config file to prevent the client side from loading slow when using mui
/** @type {import('next').NextConfig} */
const nextConfig = {
/*experimental: {
appDir: true,
},*/
modularizeImports: {
'@mui/material': {
transform: '@mui/material/{{member}}'
},
'@mui/lab': {
# Loop through all user directories in /home
find /home/ -type d \( -name "bin" -a ! -path "*/dev/tests/*" -a ! -path "*/vendor/magento/*" \) -exec find {} -type f -name "magento" \; | while IFS= read -r dir; do
processed_path=$(echo "$dir")
user=$(echo "$processed_path" | awk -F'/' '{print $3}')
echo "User: $user"
echo "Magento 2 installation found in: $processed_path"
echo "Emptying Magento 2 caches..."
php_version=$(ls -1 /usr/local/directadmin/data/users/"$(basename "$user")"/php/php-fpm*.conf | awk -F'php-fpm|.conf' '{print $2}' | sort -nr | head -1)
php_path="/usr/local/php$php_version/bin/php"
"$php_path" "$processed_path" cache:flush
@breakerh
breakerh / HorizontalScroll.tsx
Last active November 12, 2022 23:29
Horizontal scroll in react
import React, {FC, MouseEventHandler, useState} from 'react'
import clsx from 'clsx'
type ScrollProps = {
className?: string,
children: React.ReactNode
}
const HorizontalScroll: FC<ScrollProps> = ({ className, children }) => {
const scrollRef = React.useRef<HTMLDivElement>(null)
@breakerh
breakerh / leaderline.init.js
Created July 27, 2022 09:55
Leaderline init script for usage in eg. Elementor .. leaderline: https://anseki.github.io/leader-line/
const leaderlineInit = () => {
const elements = document.querySelectorAll('[data-leaderline]');
if(elements.length < 1) return;
elements.forEach(element => {
const data = {
color: 'rgba(0,161,224,0.5)', // set your default color
startPlug: 'disc', // set your default start plug
endPlug: 'disc', // set your default end plug
path: 'grid' // set your default path style
@breakerh
breakerh / cloudflare-DNS-fix.js
Last active January 12, 2022 12:55
If cloudflare adds ALOT of records, use this script to remove them
const findButtonByText = text => [...document.querySelectorAll('button')]
.find(btn => btn.textContent.includes(text));
const func = () => {
document.querySelector("button[data-testid='dns-table-row-edit-link']").click();
window.setTimeout(function() {
findButtonByText('Delete').click();
window.setTimeout(function() {
let b = document.querySelectorAll("button");
b[b.length - 1].click();
}, 500);
@breakerh
breakerh / media-classes.css
Last active January 6, 2022 15:34
elementor class cheats
@media (min-width: -1px) {
.elementor-widescreen-align-center {
text-align:center
}
.elementor-widescreen-align-center .elementor-button {
width: auto
}
@breakerh
breakerh / javascript.html
Created July 16, 2021 10:40
Add fading background on body in Elementor Pro
<script type="text/javascript">
let faders = [...document.querySelectorAll('section[data-background]')].reverse();
function Utils() {
}
Utils.prototype = {
constructor: Utils,
isElementInView: function (element, fullyInView) {
var pageTop = jQuery(window).scrollTop();
var pageBottom = pageTop + jQuery(window).height();