Skip to content

Instantly share code, notes, and snippets.

@bettysteger
bettysteger / Editorjs.vue
Last active March 30, 2025 12:59
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';
@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; ?>
@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) {
@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)
<?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 );
@odan
odan / xampp_php7_xdebug.md
Last active April 9, 2025 13:07
Installing Xdebug for XAMPP
@joseluisq
joseluisq / terminal-git-branch-name.md
Last active February 9, 2025 02:05
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() {
@danrovito
danrovito / countrydropdown.html
Last active May 5, 2025 15:08
HTML Country Select Dropdown List
<label for="country">Country</label><span style="color: red !important; display: inline; float: none;">*</span>
<select id="country" name="country" class="form-control">
<option value="Afghanistan">Afghanistan</option>
<option value="Åland Islands">Åland Islands</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
@feklee
feklee / README.md
Last active April 24, 2019 16:38
Notes and experiments concerning HTML5 streaming, with an emphasis on live streaming

Introduction

Collection of solutions for streaming via DASH, Dynamic Adaptive Streaming over HTTP, as of November 2014.

Recommended client: Chrome 38

Tool used for encoding live streams: FFmpeg

@edouard-lopez
edouard-lopez / gulpfile.js
Created May 5, 2014 15:18
Gulp copy font-awesome files to dist/ directory
'use strict';
// Generated on 2014-04-14 using generator-leaflet 0.0.14
var gulp = require('gulp');
var open = require('open');
var wiredep = require('wiredep').stream;
// Load plugins
var $ = require('gulp-load-plugins')();