Skip to content

Instantly share code, notes, and snippets.

View hailwood's full-sized avatar

Matthew Hailwood hailwood

View GitHub Profile
@hailwood
hailwood / helpers.php
Last active December 4, 2022 23:30
HMR sass support for laravel mix
<?php
if (!function_exists('isHMR')) {
/**
* Get whether HMR is active.
*
* @return bool
*/
function isHMR()
{
@hailwood
hailwood / .zshrc
Last active January 2, 2018 07:37
docker-connect/docker-ip function and autocomplete
#Setup the autocomplete
fpath=(~/.zsh/completion $fpath) #assuming the _docker-connect file is stored at ~/.zsh/completion/_docker-connect
autoload -Uz compinit && compinit -i
#The actual functions
docker-connect () {
docker exec -i -t $1 /bin/bash
}
docker-ip () {
@hailwood
hailwood / EditableTablePage.php
Last active November 6, 2015 00:47
I needed a way to share one DataObject type between multiple has_many relations on the same page without the DataObject knowing how many links it had, this solution works using `AddNewInlineButton` and `GridFieldEditableColumns`. To add an additional table the only change required is another entry in the foreach on line 13.
<?php
class EditableTablePage extends Page {
private static $has_many = [
'TableRows' => 'TableRow'
];
public function getCMSFields(){
$fields = parent::getCMSFields();
@hailwood
hailwood / ampersand-checkbox-view.js
Created October 28, 2015 23:51
Ampersand checkbox view with htmlLabel support.
var AmpersandCheckboxView = require('ampersand-checkbox-view');
module.exports = AmpersandCheckboxView.extend({
initialize: function(opts){
this._defaultInitialize(opts);
this.htmlLabel = !!opts.htmlLabel;
},
render: function(){
Requirements::customScript(<<<JS
(function($) {
$('.icp-auto').entwine({
onmatch: function(){
$('.icp-auto').iconpicker();
this._super();
},
onunmatch: function() {
this._super();
}
/* $AMPERSAND_VERSION */
var domify = require('domify');
var dom = require('ampersand-dom');
var matches = require('matches-selector');
var View = require('ampersand-view');
//Replaceable with anything with label, message-container, message-text data-hooks and a <select>
var defaultTemplate = [
'<label class="select">',
'<span data-hook="label"></span>',
<?php
for($i = 1; $i <= 10; $i++){
for($j = 1; $j <= (11-($i?:1)); $j++){
echo $i.chr(64+$j)."\n";
}
echo "--\n\n";
}
?>
BlogEntry:
default_sort: 'Date DESC'
summary_fields:
- Title
- Date
field_labels:
- Title: 'Entry Title'
- Date: 'Date Posted'
Director:
environment_type: 'dev'
Director:
rules:
'test//$Action/$ID' : 'TestPage_Controller'
'OrderModifierForm_Controller//$Action/$ID' : 'OrderModifierForm_Controller'
<?php
/**
* @description: This class helps you to manage countries within the context of e-commerce.
* For example: To what countries can be sold.
* /dev/build/?resetecommercecountries=1 will reset the list of countries...
*
*
* @authors : Nicolaas [at] Sunny Side Up .co.nz
* @package : ecommerce