Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick aNickzz

View GitHub Profile
@aNickzz
aNickzz / PageController.php
Last active Feb 14, 2020
Sync fonts to the assets dir so relative links in combined CSS will work
View PageController.php
<?php
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Core\Flushable;
use SilverStripe\Core\Path;
use SilverStripe\View\Requirements;
use SilverStripe\View\ThemeResourceLoader;
class PageController extends ContentController implements Flushable
{
@aNickzz
aNickzz / purgeTemp.js
Last active Feb 13, 2020
Delete files in a directory that are more than 7 days old and optionally create a file named with a warning message.
View purgeTemp.js
const fs = require('fs');
const path = require('path');
/* Config */
const days = 7;
const protectedFileName = `items older than ${days} day${
days == 1 ? '' : 's'
} are automatically deleted`;
const shouldCreateProtectedFile = true;
@aNickzz
aNickzz / .php_cs
Created Apr 27, 2018
php-cs-fixer config
View .php_cs
<?php
// Get more info and examples by running "php-cs-fixer describe rule_name"
$fixer = PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
/*
* Each line of multi-line DocComments must have an asterisk [PSR-5] and must
@aNickzz
aNickzz / parse_query_string.php
Last active Oct 13, 2017
Same as parse_str but don't mangle parameters with dots or spaces
View parse_query_string.php
<?php
/**
* Similar to parse_str, parses a query string and returns the resulting array.
* Does not replace '.' and ' ' with underscores.
*
* @param string $string
* @return array
*/
function parse_query_string($string) {
$parts = explode('&', $string);