Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Stay home

Guillaume Chau Akryum

🏠
Stay home
View GitHub Profile
@Akryum
Akryum / format-object.js
Created Jan 13, 2021
Format a JS object or array to JavaScript source code string
View format-object.js
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 Jan 6, 2021
Tailwind negate responsive breakpoints
View responsive-menu.html
<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>
@Akryum
Akryum / vue.config.js
Created Sep 27, 2018
Per-page split chunks
View vue.config.js
module.exports = {
pages: {
pageA: 'src/pageA.js',
pageB: 'src/pageB.js',
pageC: 'src/pageC.js',
},
chainWebpack: config => {
const options = module.exports
const pages = options.pages
@Akryum
Akryum / PostUpvoter.vue
Created Sep 22, 2016
Apollo mutation example in a Vue component
View PostUpvoter.vue
<script>
import gql from 'graphql-tag';
// GraphQL Mutation with one parameter
const upvoteMutation = gql`
mutation upvotePost($postId: Int!) {
upvotePost(postId: $postId) {
id
votes
}
@Akryum
Akryum / vue.config.js
Last active Apr 26, 2020
Auto-import styles with vue-cli 3
View vue.config.js
const path = require('path')
module.exports = {
chainWebpack: config => {
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
types.forEach(type => addStyleResource(config.module.rule('stylus').oneOf(type)))
},
}
function addStyleResource (rule) {
View file-chooser.vbs
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 Dec 15, 2019
Vue - onScrollBottom composable function
View List.vue
<script>
import { ref } from '@vue/composition-api'
import { onScrollBottom } from '@/scroll'
export default {
setup () {
function loadMore () {
// ...
}
@Akryum
Akryum / FileExplorer.vue
Last active Nov 25, 2019
Example of migration to Vue Function-based Component API
View FileExplorer.vue
<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'
@Akryum
Akryum / PostList.vue
Last active Nov 13, 2019
Example Vue component using Apollo and GraphQL
View PostList.vue
<script>
import gql from 'graphql-tag';
// GraphQL query
const postsQuery = gql`
query allPosts {
posts {
id
title
votes
@Akryum
Akryum / example.js
Last active Oct 18, 2019
Vue Router - Navigate to parent named route
View example.js
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' }
}
You can’t perform that action at this time.