Skip to content

Instantly share code, notes, and snippets.

View Alexisgt01's full-sized avatar

Alexis Gatuingt Alexisgt01

View GitHub Profile
@Alexisgt01
Alexisgt01 / Config.php
Last active July 14, 2020 19:48
Get data from a directory and merge it into an array
<?php
namespace Core\Service;
class Config
{
/**
* @var string $directory
* Directory
*/
export function download(id) {
return api.get(`url/${id}`, {
responseType: 'blob',
}).then((responseBlob) => {
let mime = require('mime-types');
let ext = mime.extension(responseBlob.headers['content-type']);
const url = window.URL.createObjectURL(new Blob([responseBlob.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.' + ext);
/*
the docs point to this file as an index of options.
when this files is moved, update the docs.
*/
/*
TODO: figure out booleans so attributes can be defined like:
<FullCalendar editable />
*/
export const PROP_DEFS = {
array.acceptedGrants.some(r => $authUser.role.grantsSerialized.includes(r))
@Alexisgt01
Alexisgt01 / timer.js
Last active November 21, 2019 14:47
Vuex multi timer methods
/* eslint-disable no-console */
/* eslint-disable no-unused-vars */
const state = {
timers: [],
};
// getters
const getters = {
timers: state => state.timers,
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@Alexisgt01
Alexisgt01 / index.vue
Last active November 21, 2019 13:02
[MODULES] Tabs page storage with Vue cli, Vuex, Vuetify & Vue Router
<template>
<div>
<v-btn @click="addPage({
name: 'Item', //Must be unique !!
route: '/item',
})"></v-btn>
</div>
</template>
<script>
/* eslint-disable no-console */
console.log(someThing);
/* eslint-enable no-console */
<a href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('frm-logout').submit();">
<form id="frm-logout" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
@Alexisgt01
Alexisgt01 / preventClosing.js
Created September 14, 2019 23:05
Prevent window close
window.onbeforeunload = confirmExit;
function confirmExit() {
return "You have attempted to leave this page. Are you sure?";
}