Skip to content

Instantly share code, notes, and snippets.

@donaldallen
donaldallen / pre-commit
Created Aug 13, 2019 — forked from ssx/pre-commit
Pre-commit hook for git with phpcs and phpcbf (auto-correct obvious violations)
View pre-commit
#!/bin/sh
PHPCS=`which phpcs`
PHPCBF=`which phpcbf`
if [ -z $PHPCS ] || [ -z $PHPCBF ]
then
printf "\n\e[38;5;255,255,255m"
printf "💥 Error: The required tools 'phpcs' and/or 'phpcbf' could not be found in your path.\n\n"
printf "You can install both tools globally by running:\n\n"
@donaldallen
donaldallen / WordPress.class.php
Created Aug 7, 2018 — forked from Jamesking56/WordPress.class.php
Read Wordpress Export XML to PHP
View WordPress.class.php
<?php
/**
* WordPress class - Manages the WordPress XML file and gets all data from that.
*/
class Wordpress
{
public static $wpXML;
@donaldallen
donaldallen / CsvActionResult.cs
Created May 29, 2018 — forked from simonech/CsvActionResult.cs
ActionResult for ASP.NET MVC that returns a CSV file from any list of objects
View CsvActionResult.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace webnetconf.website.Helpers
View acf.php
<?php
function acf_json_save_point ($path) {
return __DIR__.'/data/acf';
}
function acf_json_load_point ($path) {
return [__DIR__.'/data/acf'];
}
View preload.html
<a href="/contact">Contact me</a>
<script>
const link = document.querySelector("a");
link.addEventListener("mouseenter", () => {
const css = "<link rel=preload as=style href=contact.css>";
document.head.insertAdjacentHTML("beforesend", css);
}, {
once: true
@donaldallen
donaldallen / Performance.Dev.config
Created Jan 17, 2017 — forked from kamsar/Performance.Dev.config
SItecore 8.0/8.1 Performance Config
View Performance.Dev.config
<!--
A set of performance optimizations for development that vastly increase application startup time.
Should not be used in production, as they largely disable forensic diagnostics that you'd want there over fast startup time after a compile.
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<hooks>
<hook type="Sitecore.Diagnostics.HealthMonitorHook, Sitecore.Kernel">
<patch:delete />
View log.log
18328 13:54:20 INFO HttpModule is being initialized
18328 13:54:20 INFO
18328 13:54:20 INFO **********************************************************************
18328 13:54:20 INFO **********************************************************************
18328 13:54:20 INFO Sitecore started
18328 13:54:20 INFO Sitecore.NET 8.2 (rev. 161115)
18328 13:54:20 INFO
18328 13:54:20 INFO c:\inetpub\wwwroot\habitat.dev.local\website\bin\antlr3.runtime.dll (Antlr3.Runtime)
18328 13:54:20 INFO c:\inetpub\wwwroot\habitat.dev.local\website\bin\castle.core.dll (Castle.Core, Castle.Core 3.3.3 for .NETFramework v4.5, 3.3.3.58)
18328 13:54:20 INFO c:\inetpub\wwwroot\habitat.dev.local\website\bin\componentart.web.ui.dll ()
View gist:2f1511083478b3101a23dd6b410a4d42
/*
* This "translates" PHP module package names into system-specific names.
*/
define puphpet::php::module (
$service_autorestart
){
$package = $::osfamily ? {
'Debian' => {
View gist:7db7e145e48f783281f923d53abc5357
server {
listen [::]:80;
listen 80;
# listen on both hosts
server_name donaldallen.com www.donaldallen.com;
# and redirect to the https host (declared below)
# avoiding http://www -> https://www -> https:// chain.
return 301 https://www.donaldallen.com$request_uri;
View rewrite.php
<?php
add_filter('rewrite_rules_array', function ($rules) {
$new_rules = [];
$new_rules['^locations/(.+?)/(.+?)/(.+?)/?$'] = 'index.php?area=$matches[1]&area=$matches[2]&area=$matches[3]';
$new_rules['^locations/(.+?)/(.+?)/(.+?)/?$'] = 'index.php?area=$matches[1]&area=$matches[2]&locations=$matches[3]';
$new_rules['^locations/(.+?)/(.+?)/?$'] = 'index.php?area=$matches[1]&locations=$matches[2]';
$new_rules['^locations/(.+?)/(.+?)/?$'] = 'index.php?area=$matches[1]&area=$matches[2]';
$new_rules['^locations/(.+?)/?$'] = 'index.php?area=$matches[1]';