Skip to content

Instantly share code, notes, and snippets.

View ademers's full-sized avatar
🧡

Andrea ademers

🧡
View GitHub Profile
@m-ostadi
m-ostadi / regex.txt
Created July 1, 2022 13:43
regex for adding tailwind prefix to existing tailwind classes
in your editor (i used phpstorm ctrl+shift+f for find and replace in all files of a specific folder):
find : (?<=class=["'][^"']*)([0-9a-zA-Z_-]+\s*)(?=[^"']*["'])
replace : tw-$1
@aaronbushnell
aaronbushnell / README.md
Last active February 1, 2024 20:48
🗓 Setting up omnilight/yii2-scheduling for flexible Craft task scheduling

📦 Installation

  1. Run composer require omnilight/yii2-scheduling to install the scheduling package
  2. Setup a config/schedule.php file to house your scheduled processes
  3. Modify your config/app.php to include the schedule component details to run the Craft command (instead of yii)
  4. Run php craft schedule/run --scheduleFile=@config/schedule.php to process any scheduled operations.

💡 Tip: You likely want to run php craft schedule/run --scheduleFile=@config/schedule.php on a cron job that fires every minute!

🙏 Credits

@mattstein
mattstein / db-test.php
Last active March 28, 2023 23:01
PHP MySQL/PostgreSQL Connection Test
<?php
/**
* Database Connection Tester
* A quick-and-dirty standalone script for checking PHP’s connection to a
* MySQL (or MariaDB) or PostgreSQL database.
*
* To use, enter the settings below and run the following from your terminal:
* ```
* php -f db-test.php
@gilbertsoft
gilbertsoft / Dockerfile
Last active March 3, 2023 23:31
Easy change ImageMagick configuration to allow more file types in DDEV, add this two files to .ddev/web-build/
# Change default ImageMagick configuration to allow additional file types
ARG BASE_IMAGE
FROM $BASE_IMAGE
ADD policy.xml /etc/ImageMagick-6/policy.xml
<?php
namespace Deployer;
require 'recipe/common.php';
require 'recipe/rsync.php';
set('application', 'workingconcept/wrkcpt-craft');
set('repository', 'https://github.com/workingconcept/wrkcpt-craft');
$shared = [
name: Forge Deploy
on:
push:
branches:
# - master
- develop
jobs:
deploy:
@terryupton
terryupton / modal.twig
Created April 9, 2020 18:18
Ajax Loading a page into a modal with Alpine JS
<section x-data="{showModal: false, html: ''}">
<button
@click="html='loading...'; showLoading = true; showModal = !showModal;
fetch('{{ entry.url }}', {
method: 'GET',
headers: {
'X-Requested-With': 'XMLHttpRequest',
},
})
@daltonrooney
daltonrooney / form.js
Last active September 24, 2019 19:03
Craft CMS + Mailchimp signup form in Vue.js
import Vue from 'vue'
import axios from 'axios'
const apiClient = axios.create({
baseURL: '',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
})
@joshangell
joshangell / PhpStorm-and-Gridsome.md
Last active December 21, 2022 10:13
Quick and dirty explanation of how to get autocomplete, syntax highlighting etc when using Gridsome in PhpStorm.

PhpStorm

  1. Make sure your gridsome dev server is running: cd frontend and then yarn dev or npm run dev
  2. Install JS GraphQL plugin: https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
  3. Select everything inside <page-query>, click the light bulb icon, choose "Inject language or reference" and select GraphQL, like this:

NOTE: you only have to do this once and then all your .vue files will support GraphQL queries inside <page-query> tags.

@callaginn
callaginn / ajax-contact-form.js
Last active May 3, 2024 16:38
Shopify Ajax Contact Form
// Before implementing this, you'll need to contact Shopify support and ask them to turn off Google's ReCaptcha
// for your Shopify store's contact forms. Otherwise, it will redirect to the captcha's verification page.
// Retrieves input data from a form and returns it as a JSON object:
function formToJSON(elements) {
return [].reduce.call(elements, function (data, element) {
data[element.name] = element.value;
return data;
}, {});
}