Skip to content

Instantly share code, notes, and snippets.

View XanderLuciano's full-sized avatar

Xander Luciano XanderLuciano

View GitHub Profile
@XanderLuciano
XanderLuciano / Loops.md
Created August 16, 2018 05:48
Useful Javascript & Vue Templates

Async sleep function

Effectively an easy way to call setTimeout() from within an async function.

note: This will only wait at least this many ms before execution continues.

const sleep = ms => new Promise(res => setTimeout(res, ms));

// Usage
@hopeseekr
hopeseekr / UuidModel.php
Created April 16, 2018 18:47
A drop-dead simple UUID base model class for Laravel 5
<?php
namespace App\Models;
use Ramsey\Uuid\Uuid;
/**
* App\Models\UuidModel.
*
* @mixin \Eloquent
@srph
srph / oauth.js
Created February 21, 2016 13:50
axios: interceptor which includes your oauth token in every request as an Authorization header
import axios from 'axios';
// You can use any cookie library or whatever
// library to access your client storage.
import cookie from 'cookie-machine';
axios.interceptors.request.use(function(config) {
const token = cookie.get(__TOKEN_KEY__);
if ( token != null ) {
config.headers.Authorization = `Bearer ${token}`;
@videlais
videlais / Gamepad.js
Last active July 17, 2021 09:36
Complete Gamepad.js code
/**
* (Note: Depends on window.requestAnimationFrame for polling.)
*
* An experimental Gamepad object for detecting
* and parsing gamepad input.
*
* Current code borrows heavily from Marcin Wichary's work:
* http://www.html5rocks.com/en/tutorials/doodles/gamepad/
*
* Also uses deadzone values from