Skip to content

Instantly share code, notes, and snippets.

View ManUtopiK's full-sized avatar
:octocat:
Ready to code.

Emmanuel Salomon ManUtopiK

:octocat:
Ready to code.
View GitHub Profile
@ManUtopiK
ManUtopiK / slugify.js
Created September 2, 2021 16:42
slugify
String.prototype.slugify = function (separator = '-') {
return this.toString()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase()
.trim()
.replace(/[^a-z0-9 ]/g, '')
.replace(/\s+/g, separator)
}
@ManUtopiK
ManUtopiK / countries.js
Created December 15, 2020 22:00
World countries
const countries = [
"Afghanistan",
"Albania",
"Algeria",
"Andorra",
"Angola",
"Antigua and Barbuda",
"Argentina",
"Armenia",
"Australia",
@ManUtopiK
ManUtopiK / Editor.vue
Created November 26, 2020 00:48 — forked from Julien1138/Editor.vue
Tiptap collaboration server handles multiple document using namespaces and rooms
<template>
<div class="editor">
<template v-if="editor && !loading">
<div class="count">
{{ count }} {{ count === 1 ? 'user' : 'users' }} connected to {{ projectPath }}/{{ docName }}
</div>
<editor-content class="editor__content" :editor="editor" />
</template>
<em v-else>
Connecting to socket server …
# config.js
const config = {
...,
features: {
...
}.
...
}
function feature (name) {
return config.features[name]
@ManUtopiK
ManUtopiK / gist:f02811891a98aba6ac135c6dc2106588
Last active September 10, 2020 23:00
test gist with image

https://miro.medium.com/max/700/1*kkH8jsYRX_JNSJqz-bm07w.gif

# ----------------------------------------------------------------------
# {TYPE}: [{SCOPE}] {SUBJECT} What?
# {BODY} Why?
# {FOOTER}
@ManUtopiK
ManUtopiK / fetch-graphql-schema.js
Last active September 1, 2019 22:06 — forked from rmarscher/fetch-graphql-schema.js
Get root schema of graphql endpoint
// A script that can pull down the result of the introspection query
// from a running graphql server.
// Dependencies:
// npm i -S isomorphic-fetch graphql-tag graphql apollo-client
// Usage:
// node fetch-graphql-schema [graphql url]
// Example:
@ManUtopiK
ManUtopiK / ratelimit.js
Last active July 3, 2022 09:16
rate limiting javascript generator
async function* rateLimit(limit, time) {
let count = 0;
while(true) {
if(count++ >= limit) {
await delay(time);
count = 0;
}
yield; // Let's execute next code
}
}
@ManUtopiK
ManUtopiK / plugins.js
Created August 27, 2019 14:27
Import multiple svg in nuxt
import Vue from 'vue'
import forEach from 'lodash/forEach'
const icons = require.context('~/icons', false, /[A-Z]\w+\.(svg)$/)
forEach(icons.keys(), (fileName) => {
const iconConfig = icons(fileName)
const iconName = fileName.split('/').pop().split('.')[0]
Vue.component(iconName, iconConfig.default || iconConfig)
})
@ManUtopiK
ManUtopiK / clean-graphql.js
Last active May 5, 2024 20:11
Clean graphql response : Remove edges, node and __typename from graphql response
/**
* Remove edges, node and __typename from graphql response
*
* @param {Object} input - The graphql response
* @returns {Object} Clean graphql response
*/
const cleanGraphQLResponse = function(input) {
if (!input) return null
const output = {}
const isObject = obj => {