Skip to content

Instantly share code, notes, and snippets.

View nathanbarrett's full-sized avatar

Nathan Barrett nathanbarrett

View GitHub Profile
@nathanbarrett
nathanbarrett / Dropzone.vue
Last active December 1, 2018 14:40
A Vue component wrapper for dropzone.js that emits all events
<template>
<div :id="id" class="uploader dropzone"></div>
</template>
<script>
import Dropzone from 'dropzone';
Dropzone.autoDiscover = false;
export default {
@nathanbarrett
nathanbarrett / GuessesMimeTypesAndExtentions.php
Created January 17, 2018 16:44
Trait for guessing mime types and extensions of files
<?php
namespace App\Traits;
// composer require ralouphie/mimey
use Mimey;
trait GuessesMimeTypesAndExtentions
{
/**
* Guesses the mime type of a file based off of the extension in the file name
@nathanbarrett
nathanbarrett / dom-script-loader.service.ts
Created December 9, 2017 18:29
A helper service for async loading of libraries such as google maps , google charts , etc
import { Injectable } from '@angular/core';
import Promise from 'bluebird'
@Injectable()
export class DomScriptLoaderService {
constructor() { }
/**
* Returns a Promise with a boolean value as to whether is was previously loaded or not
@nathanbarrett
nathanbarrett / planets.js
Created October 2, 2017 17:44
A list of all the planets and distances
var solarSystem = [
{
name: 'The Sun',
diameter: 1391400000,
distance: 0
},
{
name: 'Mercury',
diameter: 4879000,
distance: 57909227000
@nathanbarrett
nathanbarrett / getFromGPlace.ts
Last active March 30, 2017 23:20
Typescript function to get address components from a google place result. Some aliases thrown in for help
class Utils {
placeAddressComponents = {
street_number: {
selector: 'street_number',
defaultName: 'long_name',
},
route: {
selector: 'route',
defaultName: 'short_name',
@nathanbarrett
nathanbarrett / crud.service.js
Last active January 9, 2017 20:50
Angular 1.X helper service for helping with crud tasks
/*
* A backend service for other services wanting crud operations
*
* @params
*
* @returns none
*/
(function () {
@nathanbarrett
nathanbarrett / UsStates.php
Created December 12, 2016 16:49
PHP Class that allows you to access AND format the US States in an array format of your choosing
<?php
namespace App\Helpers;
/*
* Access the US States in a format of your choosing by simply calling:
* UsStates::getStates(array $format, bool $stateAllCaps, bool $includeTerritories)
* check the getStates method below for more details on how to format
*/
class UsStates
{
public static $usStates = [
@nathanbarrett
nathanbarrett / newlaravel
Created July 18, 2016 17:29
bash function for setting up a laravel project with stuff I almost always use
function newlaravel
{
# Modify to suit your own system
YAML=/home/users/Nathan/Homestead.yaml
PROJECTSDIR="/media/nathan/Secondary Storage/Github"
HOMESTEADDIR="/media/nathan/Secondary Storage/Github"
HOSTFILE=/etc/hosts
PROJECTNAME=$1
#
/*
* Gets the distance in meters from two coordinate objects
*
* @params coord1 (object|required), coord2 (object|required)
*
* @returns int meters
*/
function distanceBetweenCoords(coord1, coord2){
var R = 6371000; // earth's radius in meters
@nathanbarrett
nathanbarrett / exception.service.js
Created April 25, 2016 19:00
Basic exception logging service for Angular
/*
* Angular service for exception handling and reporting
*
* @params none
*
* @returns none
*/
ExceptionService.$inject = ['$log', '$http'];