Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍🚀
coding something...

Ashley Clarke clarkeash

👨‍🚀
coding something...
View GitHub Profile
@clarkeash
clarkeash / nodemon.json
Created Mar 11, 2020
Nodemon config for Laravel
View nodemon.json
{
"events": {
"start": "clear",
"restart": "clear"
},
"exec": "php artisan test",
"ext": "*",
"ignore": [
"vendor/"
]
View this.php
<?php
class This {
protected $this;
public function __construct ()
{
$this->this = $this;
}
@clarkeash
clarkeash / validate_email.php
Created Aug 15, 2012
PHP function to validate an email address
View validate_email.php
<?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 Feb 9, 2016
Laravel TestCase Improved
View TestCase.php
<?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 Jan 27, 2016
Standard phpunit configuration. (adapted from Laravel)
View phpunit.xml
<?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 Dec 5, 2013
New to objects in JS, no idea of the differences here: (why would you use one over the other)
View object_one.js
function Object(){
}
Object.prototype.func = function(){
//code
};
View StringToArrayWithMultipleSplitsThingy.php
<?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 Dec 19, 2015
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.
View roundToBaseFunction.php
<?php
function roundToBase($value, $base = 2)
{
$result = log($value, $base);
$result = ceil($result);
$result = pow($base, $result);
return $result;
}
View validator.js
'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 Dec 14, 2015
Replacement for l4 app.php file.
View app.php
<?php
return array(
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with