Skip to content

Instantly share code, notes, and snippets.

View Akryum's full-sized avatar
☮️
Meow

Guillaume Chau Akryum

☮️
Meow
View GitHub Profile
@Akryum
Akryum / dedupeApolloReferences.js
Created April 2, 2021 15:31
Dedupe Apollo Client 3 references in merge
function dedupeReferences (existing, incoming) {
// Dedupe items
const idMap = {}
for (const item of existing) {
idMap[item.__ref] = true
}
const validated = []
for (const item of incoming) {
if (!idMap[item.__ref]) {
validated.push(item)
@Akryum
Akryum / eager-computed-options-alt.ts
Last active September 14, 2023 08:59
Eager Vue computed property - use for cheap computed properties that always update but that don't trigger updates when their value doesn't change
export function useEagerComputed() {
const properties = []
function eagerComputed(definitions) {
const computedProps = {}
for (const key in definitions) {
const effect = definitions[key]
properties.push({ key, effect })
computedProps[key] = function () {
return this.$data[key]
<link rel="stylesheet" href="https://cdn.rawgit.com/luizbills/feather-icon-font/v4.7.0/dist/feather.css">
@Akryum
Akryum / format-object.js
Created January 13, 2021 23:02
Format a JS object or array to JavaScript source code string
const KEY_ESCAPE_REG = /[\s-.:|#@$£*%]/
const MAX_SINGLE_LINE_ARRAY_LENGTH = 3
export function formatObjectToSource (obj) {
return printLines(Array.isArray(obj) ? arrayToSourceLines(obj) : objectToSourceLines(obj))
}
function objectToSourceLines (object, indentCount = 0) {
return createLines(indentCount, lines => {
lines.push('{')
@Akryum
Akryum / responsive-menu.html
Created January 6, 2021 15:22
Tailwind negate responsive breakpoints
<div class="flex !md:flex-col items-center !md:space-y-6 md:space-x-6">
<button>Menu button 1</button>
<button>Menu button 2</button>
<button>Menu button 3</button>
</div>
Option Explicit
WScript.Echo ChooseFile( )
Function ChooseFile( )
' Select File dialog based on a script by Mayayana
' Known issues:
' * Tree view always opens Desktop folder
' * In Win7/IE8 only the file NAME is returned correctly, the path returned will always be C:\fakepath\
@Akryum
Akryum / List.vue
Created December 15, 2019 14:40
Vue - onScrollBottom composable function
<script>
import { ref } from '@vue/composition-api'
import { onScrollBottom } from '@/scroll'
export default {
setup () {
function loadMore () {
// ...
}
@Akryum
Akryum / example.js
Last active June 13, 2022 17:28
Vue Router - Navigate to parent named route
export default {
const parents = getNamedParents(this.$router.options.routes, this.$route.matched)
if (parents.length) {
return {
name: parents[parents.length - 1].name,
}
}
return { name: 'home' }
}
@Akryum
Akryum / App.vue
Last active September 30, 2019 11:03
<template>
<div id="app">
<RouteController />
<nav>...</nav>
<router-view/>
</div>
</template>
@Akryum
Akryum / FileExplorer.vue
Last active November 25, 2019 18:29
Example of migration to Vue Function-based Component API
<script>
import { isValidMultiName } from '@/util/folders'
import FOLDER_CURRENT from '@/graphql/folder/folderCurrent.gql'
import FOLDERS_FAVORITE from '@/graphql/folder/foldersFavorite.gql'
import FOLDER_OPEN from '@/graphql/folder/folderOpen.gql'
import FOLDER_OPEN_PARENT from '@/graphql/folder/folderOpenParent.gql'
import FOLDER_SET_FAVORITE from '@/graphql/folder/folderSetFavorite.gql'
import PROJECT_CWD_RESET from '@/graphql/project/projectCwdReset.gql'
import FOLDER_CREATE from '@/graphql/folder/folderCreate.gql'