Skip to content

Instantly share code, notes, and snippets.

View hailwood's full-sized avatar

Matthew Hailwood hailwood

View GitHub Profile
@hailwood
hailwood / example.js
Created February 17, 2020 21:21
Promised Interval
const interval = new PromisedInterval(async () => {
//Do something here
}, 5000);
// Start the loop running
interval.start(); // you can await this if you'd like to pause until something stops the interval
// Pause the execution after the current loop finishes
@hailwood
hailwood / AlternateMailerServiceProvider.php
Created September 25, 2019 01:56
Laravel Alternative Mailer
<?php
namespace App\Services\AlternateMailer;
use Illuminate\Mail\Mailer;
use Swift_Mailer;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Swift_DependencyContainer;
use Illuminate\Support\ServiceProvider;
<?php
namespace App\Eloquent\Concerns;
use Illuminate\Support\Str;
use App\Eloquent\Relationships\LeaveableMorphToMany;
/**
* Trait HasCustomRelationships
*
<?php
/**
* Improved GridFieldExportButton that streams CSV data to the client instead of building
* the entire CSV in memory and sending that (which doesn't work for large data sets).
*/
class GridFieldStreamExportButton extends GridFieldExportButton
{
/**
version: '3'
services:
web:
image: brettt89/silverstripe-web
working_dir: /var/www
ports:
- 8080:80
volumes:
- .:/var/www/html
@hailwood
hailwood / example.ts
Created June 13, 2018 03:42
Typescript: Exclusive Or properties
type ExcludeXORIncludeXORNeither<T extends Serializer<T>> =
| { exclude: object; include?: never; }
| { exclude?: never; include: object; }
| { exclude?: never; include?: never; };
abstract class Serializer<T extends Serializer<T> & ExcludeXORIncludeXORNeither<T>> {
exclude?: object;
include?: object;
}
<?php
namespace App\Http\Resources;
use App\Models\CropType;
use Illuminate\Http\Resources\Json\ResourceCollection;
class CropTypeCollectionResponse extends ResourceCollection
{
/**
@hailwood
hailwood / example.php
Last active September 14, 2017 02:32
class Creature extends Model {
protected $with = [
'entity'
];
public function entity(){
return $this->morphTo();
}
null
java.lang.StackOverflowError
at com.intellij.openapi.util.Pair.hashCode(Pair.java:88)
at gnu.trove.TObjectCanonicalHashingStrategy.computeHashCode(TObjectCanonicalHashingStrategy.java:8)
at com.intellij.util.containers.RefHashMap$HardKey.set(RefHashMap.java:147)
at com.intellij.util.containers.RefHashMap$HardKey.access$500(RefHashMap.java:136)
at com.intellij.util.containers.RefHashMap.containsKey(RefHashMap.java:212)
at com.intellij.util.containers.WeakHashMap.containsKey(WeakHashMap.java:36)
at mobi.hsz.idea.gitignore.lang.IgnoreLanguage.getOuterFiles(IgnoreLanguage.java:223)
at mobi.hsz.idea.gitignore.indexing.ExternalIndexableSetContributor.getAdditionalFiles(ExternalIndexableSetContributor.java:90)
/* This is the main layout component */
class Full extends Component {
static propTypes = {
viewer: React.PropTypes.object.isRequired
};
render() {
return (