Skip to content

Instantly share code, notes, and snippets.

@joseluisq
joseluisq / terminal-git-branch-name.md
Last active November 26, 2025 12:38
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@odan
odan / xampp_php7_xdebug.md
Last active October 13, 2025 22:45
Installing Xdebug for XAMPP
<?php
/**
* Only allow one payment plan purchase (Subscription) at a time
*/
add_filter( 'woocommerce_add_to_cart_validation', 'woo_block_sub', 10, 2 );
function woo_block_sub( $valid, $product_id ) {
// Get the current product
$current_product = wc_get_product( $product_id );
@atinux
atinux / async-foreach.js
Last active April 2, 2025 11:34
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@Qoraiche
Qoraiche / subscription-payment-complete.php
Last active March 31, 2018 14:44
Woocommerce_subscription when a payment is made on a subscription
/*
* woocommerce_subscription_payment_complete action hook
* Triggered when a payment is made on a subscription
* @param $subscription
*/
add_action( 'woocommerce_subscription_payment_complete', 'update_user', 10, 1 );
function update_user($subscription) {
@gpbeer
gpbeer / first-letter-group.php
Last active July 25, 2021 19:16
PHP Group array by first letter
<?php if (!empty($items)): ?>
<ul>
<?php $current_letter = ''; ?>
<?php foreach ($items as $item) : ?>
<?php $first_letter = mb_substr($item['post_title'], 0, 1, "UTF-8"); ?>
<?php if ($first_letter != $current_letter) : ?><li><?php endif; // group list ?>
<?php if ($first_letter != $current_letter) : ?>
<h2><?php echo $first_letter; ?></h2>
<?php $current_letter = $first_letter; ?>
<?php endif; ?>
@bettysteger
bettysteger / Editorjs.vue
Last active December 9, 2025 05:29
Vue 3 SFC for Editor.js using v-model with own custom vue component
<template>
<div class="editorjs" ref="htmlelement"></div>
</template>
<script setup>
import EditorJS from '@editorjs/editorjs';
import EmbedTool from '@editorjs/embed';
import ListTool from '@editorjs/list';
import ImageTool from '@editorjs/image';
import VideoTool from './editorjs/video.js';
import { onMounted, onUnmounted, ref, watch } from 'vue';