Skip to content

Instantly share code, notes, and snippets.

Jonas Galvez galvez

Block or report user

Report or block galvez

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pool.js
import os from 'os'
import consola from 'consola'
// Usage:
//
// const handler = (file) => console.log(file)
// const pool = new PromisePool(['file1', 'file2', ...], handler)
// await pool.done()
const failureInterval = 3000
View BlobImage.vue
<template>
<img ref="img" />
</template>
<script>
export default {
props: ['src'],
data: () => ({ blob: null }),
beforeMount () {
this.$watch('src', this.loadImage)
View module-utils.js
export class ModuleUtils {
static mixin(target) {
for (const member of Object.getOwnPropertyNames(ModuleUtils.prototype)) {
target[member] = ModuleUtils.prototype[member].bind(target)
}
}
resolvePath(...args) {
return resolve(process.cwd(), ...args)
}
View timing.client.js
import Vue from 'vue'
function componentInject(key, setter) {
const installKey = `__component_inject_${key}`
if (Vue[installKey]) {
return
}
Vue[installKey] = true
const componentKey = `$${key}`
const privateKey = `_${key}`
View wrapAt.js
function wrapAt (str, max) {
if (str.length > max) {
const parts = str.split(' ')
let i = 0
for (let w = 0; i < parts.length; i++) {
w += parts[i].length
if (w >= max) {
parts[i] = `\n${parts[i]}`
w = 0
}
View nootropic-frappuccino.md

Nootropic Frappuccino

This comes from years of personal experience tweaking the recipe. I also recommend studying Ray Peat's articles for general knowledge and understanding of metabolism. Make up your own mind.

Ingredients are listed in the order I put them in the mixer.

Some of the powder tends to stick to the sides -- use a spoon to scrape while mixing if necessary.

View makeSymbols.js
export default function makeSymbols (...symbols) {
return symbols.reduce((obj, s) => ({ ...obj, [s]: Symbol.for(s) }), {})
}
View apistore.js
// APIStoreProps are properties that need to be
// ignored when running APIStore.makeStore()
const APIStoreProps = ['use', 'classes', 'constructor', 'init', 'state']
// getMethods returns methods defined
// in a given class' prototype, except init and constructor
const getMethods = (cls) => {
return Object.getOwnPropertyNames(cls.prototype)
.reduce((obj, prop) => {
View white-rose.py
#!/usr/bin/python
from time import sleep
from pygame import mixer
mixer.init()
# Download file from https://freesound.org/people/Koyber/sounds/160483/
mixer.music.load('white-rose.mp3')
mixer.music.play()
View nuxt.config.js
module.exports = {
build: {
loaders: [
{
test: /\.(png|jpe?g|gif|svg)$/,
loader: 'url-loader',
query: {
limit: 1000, // 1KO
name: 'img/[name].[hash:7].[ext]'
}
You can’t perform that action at this time.