Skip to content

Instantly share code, notes, and snippets.

View msbrime's full-sized avatar
Will code for coffee

Salis Braimah msbrime

Will code for coffee
View GitHub Profile
@msbrime
msbrime / add_time.js
Created April 2, 2019 09:14
Add days to a date in javascript. Can use in conjunction with `setHours` to get the exact time of a specific day
function addDaysToDate(date,numberOfDays){
return new Date(
date.getTime() +
daysToMilliseconds(numberOfDays)
);
}
function daysToMilliseconds(days){
return days * 86400000
}
@msbrime
msbrime / ratchet-dispatcher.js
Created March 23, 2019 13:24
A dispatcher for twbs/ratchet that fires events on page/route change
window.Dispatcher = (function(win){
var instance;
function init(){
var
callbackRegister = {},
pageCheck;
@msbrime
msbrime / git_remove_residual_files_and_folders.sh
Last active September 11, 2018 21:04
Remove leftover files and folders when you switch your working branch
git reset --hard && git clean -f -d
@msbrime
msbrime / getBrowserEvents.js
Created October 29, 2017 19:34
Get all events supported by a particular browser
function getBrowserEvents ()
{
var browserEvents = [];
for (var e in document) if (typeof document[e] !== "function" && e !== null && e.substring(0, 2) === "on") browserEvents[browserEvents.length] = e.substring(2);
return browserEvents;
}
@msbrime
msbrime / Dispatcher.js
Created August 2, 2017 23:12
A general purpose event dispatcher
/** @constructor */
function Dispatcher(context, events) {
this.ctx = context;
this.events = events;
this.listeners = {};
}
/**
* Adds an event listener to an event
*
@msbrime
msbrime / ApiResponse.php
Last active July 25, 2017 16:25
A wrapper for guzzle http responses from an API
<?php
namespace App\Library\Response;
use GuzzleHttp\Message\Response;
class ApiResponse
{
/*
* The status code of a response represented as a single integer
* denoting the general status of the response
@msbrime
msbrime / SpreadSheetGenerator.php
Created July 25, 2017 16:20
A spreadsheet generator implementation that uses PHPEXCEL
<?php
namespace App\Library\Generators;
use PHPExcel\PHPExcel;
use PHPExcel\PHPExcel_IOFactory;
use PHPExcel\PHPExcel_Cell;
class SpreadSheetGenerator{
@msbrime
msbrime / AjaxValidatableRequest.php
Created July 25, 2017 16:17
An extension of TrimmedFormRequest.php.Makes requests validate only and does not submit after validation passes but rather returns a json response
<?php
namespace App\Http\Requests;
use Illuminate\Validation\ValidationException;
/**
* Description of AjaxValidatableFormRequest
*
* @author msalisu
*/
@msbrime
msbrime / TrimmedFormRequest.php
Created July 25, 2017 16:14
A form request that trims the parameters that are sent to it
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
/**
* Description of AjaxValidatableFormRequest
*
* @author msalisu
*/
@msbrime
msbrime / test.scala
Created November 2, 2016 09:05 — forked from jdesiloniz/test.scala
A Gist
val meaningOfLife = 42