Skip to content

Instantly share code, notes, and snippets.

@sasin91
sasin91 / helpers.php
Created April 24, 2018 10:12
Incensitive string contains
if (! function_exists('istr_contains')) {
/**
* Insensitively check if given haystack contains anything like the given needle(s).
*
* @param string $haystack
* @param string[] $needles
* @return boolean
*/
function istr_contains($haystack, $needles = [])
{
@sasin91
sasin91 / file-queue.js
Last active April 15, 2018 11:32
Js file queue
import { map, forEach } from 'lodash';
class FileUploadQueue {
/**
* Create the upload queue
*
* @param Array | Object supported [{name:'photos', mime:'image'}]
* @return void
*/
constructor (supported = []) {
@sasin91
sasin91 / DateRange.php
Created April 13, 2018 11:55
Easily create a collection of dates within range of two dates.
<?php
namespace App\Support;
use ArrayIterator;
use Countable;
use DatePeriod;
use DateTime;
use DateInterval;
use IteratorAggregate;
@sasin91
sasin91 / helpers.php
Created April 9, 2018 11:43
Determine whether given input is a valid date or not
function is_date($value): bool
{
if ($value instanceof DateTime) {
return true;
}
if ((! is_string($value) && ! is_numeric($value)) || strtotime($value) === false) {
return false;
}
@sasin91
sasin91 / TrinityCoreInstaller.sh
Created March 26, 2016 13:29
TrinityCore Installer bash script
#! /bin/bash
# Since bash is following a Procedural execution, defining functions first is required.
runInstaller ()
{
ValidateAndInstallDependencies
valiteUserAndEnterHome
cloneRepoAndEnterDirectory
setupDatabase
@sasin91
sasin91 / CacheAdaptor.php
Created January 21, 2016 22:27
Cache Adapter
<?php
namespace Vitanova\Utilities;
use Illuminate\Contracts\Cache\Repository;
use Psr\Cache\CacheItemInterface,
Psr\Cache\CacheItemPoolInterface,
Psr\Cache\InvalidArgumentException;