Skip to content

Instantly share code, notes, and snippets.

View clarkeash's full-sized avatar
👨‍🚀
coding something...

Ashley Clarke clarkeash

👨‍🚀
coding something...
View GitHub Profile
@clarkeash
clarkeash / nodemon.json
Created March 11, 2020 11:19
Nodemon config for Laravel
{
"events": {
"start": "clear",
"restart": "clear"
},
"exec": "php artisan test",
"ext": "*",
"ignore": [
"vendor/"
]
@clarkeash
clarkeash / this.php
Last active September 20, 2016 14:31
<?php
class This {
protected $this;
public function __construct ()
{
$this->this = $this;
}
@clarkeash
clarkeash / validate_email.php
Created August 15, 2012 00:36
PHP function to validate an email address
<?php
function check_valid_email($email) {
$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
if (preg_match($regex, $email)) {
return true;
} else {
return false;
}
}
@clarkeash
clarkeash / TestCase.php
Last active February 9, 2016 07:55
Laravel TestCase Improved
<?php
class TestCase extends Illuminate\Foundation\Testing\TestCase
{
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
@clarkeash
clarkeash / phpunit.xml
Last active January 27, 2016 16:01
Standard phpunit configuration. (adapted from Laravel)
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
@clarkeash
clarkeash / object_one.js
Created December 5, 2013 15:31
New to objects in JS, no idea of the differences here: (why would you use one over the other)
function Object(){
}
Object.prototype.func = function(){
//code
};
<?php
function splitAndStrip($str, $del = ',')
{
$str = explode($del, $str);
for ($i=0; $i < count($str); $i++)
{
$str[$i] = trim($str[$i]);
}
return $str;
}
@clarkeash
clarkeash / roundToBaseFunction.php
Last active December 19, 2015 13:18
Function for rounding any number to the value of a specified base. e.g. If using base 2 (1,2,4,8,16,32,64,128....) the 17 would round up to 32.
<?php
function roundToBase($value, $base = 2)
{
$result = log($value, $base);
$result = ceil($result);
$result = pow($base, $result);
return $result;
}
'use strict';
var sr = {};
sr.Validator = function(){
this.errors = [];
this.messages = {
required: 'The :input: is required',
email: 'The :input: is not a valid email address',
@clarkeash
clarkeash / app.php
Last active December 14, 2015 04:18
Replacement for l4 app.php file.
<?php
return array(
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with