Skip to content

Instantly share code, notes, and snippets.

View jmsfwk's full-sized avatar

James Fenwick jmsfwk

View GitHub Profile
@jmsfwk
jmsfwk / Context.php
Created February 5, 2018 11:55
Class to send data to template that tries to avoid exceptions when data does not exists
<?php
use ArrayAccess;
use ArrayIterator;
use IteratorAggregate;
class Context implements ArrayAccess, IteratorAggregate
{
/** @var array */
private $data;
@jmsfwk
jmsfwk / Computus.php
Created March 25, 2017 15:23
A couple of algoritms for calculating the date of Easter
<?php
class Computus
{
public static function gauss(int $year)
{
$a = $year % 19;
$b = $year % 4;
$c = $year % 7;
@jmsfwk
jmsfwk / .sass-lint.yml
Created February 7, 2017 11:07
SASS Lint
# sass-lint config generated by make-sass-lint-config v0.1.2
#
# The following scss-lint Linters are not yet supported by sass-lint:
# PrivateNamingConvention
files:
include: '**/*.s+(a|c)ss'
options:
formatter: stylish
merge-default-rules: true
@jmsfwk
jmsfwk / List.php
Created November 16, 2016 10:12
Single type array class in PHP
<?php
final class List implements ArrayAccess
{
protected $type;
protected $array = [];
function __construct($var)
{
@jmsfwk
jmsfwk / ruleset.xml
Created September 30, 2016 11:25
Laravel PHPMD ruleset
<?xml version="1.0"?>
<ruleset name="Clean Code Rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
The Clean Code ruleset contains rules that enforce a clean code base. This includes rules from SOLID and object calisthenics.
@jmsfwk
jmsfwk / .profile
Created August 11, 2016 08:58
Homestead shell function
function homestead() {
( cd ~/Homestead && vagrant $* )
}
function art() {
( php artisan $* )
}
@jmsfwk
jmsfwk / styles.less
Created July 15, 2016 22:15
Atom styles for Monoisome in html
atom-text-editor {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-webkit-font-feature-settings: "liga" on, "calt" on;
}
atom-text-editor[data-grammar*="text html"] {
font-family: Monoisome;
}
@jmsfwk
jmsfwk / validators.py
Created May 26, 2016 11:22
Django FileTypeValidator
from django.core.validators import ValidationError
from django.utils.deconstruct import deconstructible
from django.utils.translation import ugettext_lazy as _
@deconstructible
class FileTypeValidator(object):
"""
Validates that an uploaded file has an allowed extension.
@jmsfwk
jmsfwk / validators.py
Created May 26, 2016 11:21
Django FileTypeValidator
from django.core.validators import ValidationError
from django.utils.deconstruct import deconstructible
from django.utils.translation import ugettext_lazy as _
@deconstructible
class FileTypeValidator(object):
"""
Validates that an uploaded file has an allowed extension.
@jmsfwk
jmsfwk / config.json
Created April 19, 2016 10:39 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",