Skip to content

Instantly share code, notes, and snippets.

View lloydjatkinson's full-sized avatar
🌧️
Chilling

Lloyd Atkinson lloydjatkinson

🌧️
Chilling
  • England
  • 06:45 (UTC +01:00)
View GitHub Profile
@lloydjatkinson
lloydjatkinson / Loading.vue
Last active June 30, 2021 10:39
A Vue component that conditionally renders slots depending on the combination of "loading" and "failed" props.
<template>
<div>
<slot
v-if="showLoadingState"
name="loading">
<div>
Loading...
</div>
</slot>
https://bolinwoodturners.co.uk/
https://www.one2onecaraudio.co.uk/
http://walkingforpaws.co.uk/
https://www.barracudascuba.co.uk/
http://www.nottsgates.com/
https://www.mpm-ltd.co.uk/
https://www.nottinghamshirehealthcare.nhs.uk/
https://www.elmbanknursinghome.co.uk/
https://www.woodthorpegarage.co.uk/
http://st-james-nottingham.org.uk/
@lloydjatkinson
lloydjatkinson / Example.md
Created January 22, 2021 14:15
Vue Dialog/Modal/Toast component with v-model binding for closing and opening

Dialog.vue:

<template>
    <div>
        <button @click="close">Close</button>
        <slot />
    </div>
@lloydjatkinson
lloydjatkinson / list.txt
Created October 27, 2020 20:45
Discord Bad Users List
this list will contain discord users that are to be preemptively banned due to their toxicity
computed: {
hasScrolledNearEnd () {
return !inRange(this.scrollView.endIndex, this.notifications.length - 5);
},
},
watch: {
hasScrolledNearEnd (nearEnd, previousValue) {
if (nearEnd && !previousValue) {
this.updateNotifications();
}
import axios from 'axios';
const rocketEndpoint = 'https://api.spacexdata.com/v3/rockets';
const upcomingLaunchesEndpoint = 'https://api.spacexdata.com/v3/launches/upcoming';
const getRockets = async () => {
try {
return {
success: true,
data: (await axios.get(rocketEndpoint)).data
@lloydjatkinson
lloydjatkinson / trim-text.js
Last active December 5, 2022 19:26
Trim text and prefix ellipses when the text length is greater than the maximum
const trimText = (input = '', maximumLength = 80) => {
const exceedsMaximum = input.length >= maximumLength;
return {
exceedsMaximum,
text: exceedsMaximum ? `${ input.substr(0, input.lastIndexOf(' ', maximumLength)) }...` : input,
}
};
export default trimText;
export const filterCollection = <TOriginal>(originalCollection: TOriginal[], search: (item: TOriginal) => boolean) => {
const result = originalCollection.filter(search);
return {
anyMatches: result.length > 0,
originalCollection,
filteredCollection: result
};
};
import { filterCollection } from './filter-collection';
@lloydjatkinson
lloydjatkinson / 42.js
Created July 16, 2019 13:46
42: The answer to life, the universe, and everything
// See if you can figure it out.
+(!+[]+!![]+!![]+!![]+[]+(!+[]+!![]+[]));
// 42
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/strongly-recommended',
'plugin:vue/recommended',
'plugin:vue/essential',
'@vue/airbnb',