Skip to content

Instantly share code, notes, and snippets.

@cballenar
cballenar / copy-files-based-on-target-source-lists.py
Created September 18, 2023 13:56
Copy Files Based on Lists of Source and Target Locations A script to move files from their respective source location (s) to the desired target location (t). Where each s and t locations are stored as separate lists of paths, each in a separate line, in text files, sources.txt and targets.txt respectively.
"""
Copy Files Based on Lists of Source and Target Locations
A script to move files from their respective source location (s) to the desired
target location (t). Where each s and t locations are stored as separate lists
of paths, each in a separate line, in text files, sources.txt and targets.txt respectively
"""
import os
import shutil
# let's make sure we log everything that happens here
<?php
namespace yournamespace\yourplugin;
use Craft;
class MyClass
{
/**
* Basic Logging implementation
@cballenar
cballenar / toggleSummaryMessage.js
Last active December 11, 2022 12:16
Toggle Summary Message. Changes the content of a details' summary to indicate whether clicking it will open or close it. Assumes the <summary> lies directly under the <details> tag and contains `data-message-open` and `data-message-close` attributes with the respective values for each case. View demo: https://codepen.io/cballenar/pen/PoagMxz
/**
* Toggle Summary Message.
* Changes the content of a details' summary to indicate whether clicking it
* will open or close it. Assumes the <summary> lies directly under the
* <details> tag and contains `data-message-open` and `data-message-close`
* attributes with the respective values for each case.
*
* @param {Event} event
*/
function toggleSummaryMessage(event) {
@cballenar
cballenar / compare-rectangle-ratios-visually.html
Last active April 5, 2022 14:05
Compare Rectangle Ratios Visually
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Image Ratios Comparisons</title>
</head>
<body>
<div id ="app" class="container"></div>
</body>
@cballenar
cballenar / drupal-js-iffe.vscode.snippet
Created January 14, 2022 16:00
Visual Code Snippet for Drupal's Immediately Invoked Function Expression (IFFE). Add to your JS snippets configuration in VS and call it with `drif`.
"Drupal IFFE": {
"prefix": "drif",
"body": [
"/**",
"* @name ${1:ScriptName}",
"* @description ${2:Script description.}",
"* @param {string} input",
"* @returns {string} output",
"*/",
"(function ($, window, Drupal) {",
@cballenar
cballenar / pacer.js
Created October 31, 2021 19:50
Iterate over an array and process each item in a promise with a given delay. Ideal if you need to run items at a set or variable pace. As used in https://github.com/cballenar/propertygrubber to delay items due to timeouts possibly put in place to stop crawlers.
/**
* Pacer
* Iterate over an array and process each item in a promise with a given delay.
* Ideal if you need to run items at a set or variable pace. As used in
* https://github.com/cballenar/propertygrubber to delay items due to timeouts
* possibly put in place to stop crawlers.
*
* @param {Array} list List of items to process
* @param {Number} delay Time in milliseconds to delay each item
* @returns {Array} New list of processed items
@cballenar
cballenar / lemp-provision.sh
Last active February 2, 2023 04:42
LEMP Provisioning script based on Laravel Forge. Generated on 2020-04-26.
# LEMP Provisioning Script
# - Script generated by Laravel Forge on 20200426
# - Built for Ubuntu 18.04LTS, PHP7.2, MySQL5.7
# Variables
#-------------------------------------------------------------------------------
my_hostname="" # mydomain
my_username="" # myuser
my_root_pw="" # ****************
my_sshkey="" # ssh-rsa AAAA...
@cballenar
cballenar / Vagrant.bootstrap.sh
Created July 3, 2017 14:16 — forked from asmerkin/Vagrant.bootstrap.sh
A simple LAMP Vagrantfile and Bootstrap file for Vagrant and ubuntu/trusty64 box. It uses mpm-workers and php5-fpm + some extra tools like grunt, gulp and composer.
#!/usr/bin/env bash
# ---------------------------------------
# Virtual Machine Setup
# ---------------------------------------
# Adding multiverse sources.
cat > /etc/apt/sources.list.d/multiverse.list << EOF
deb http://archive.ubuntu.com/ubuntu trusty multiverse
deb http://archive.ubuntu.com/ubuntu trusty-updates multiverse

Notes regarding VPS setup

Making Craft Play Nicely With MySQL 5.7.5+

Create /etc/mysql/conf.d/sql_mode.cnf

[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Source: Craft Cook Book

https://gist.github.com/jerry-gdd/d3ccbf01b4d5cde3db54a1b502d04b36
https://github.com/johanneslamers/craft-workflow/blob/master/install.sh
https://askubuntu.com/questions/866985/phpenmod-mcrypt-and-phpenmod-mbstring-return-errors
http://stackoverflow.com/questions/23921117/disable-only-full-group-by/31058962#31058962