Skip to content

Instantly share code, notes, and snippets.

View midudev's full-sized avatar
👾
Streaming! https://twitch.tv/midudev

Miguel Ángel Durán midudev

👾
Streaming! https://twitch.tv/midudev
View GitHub Profile
@midudev
midudev / bench.js
Created February 2, 2023 21:34
bench
const { beginBench } = require('@agarimo/bench')
const bench = beginBench({
duration: 1000,
transactionsPerRun: 1000
})
bench.add('forEach', () => {
const array = Array.from({ length: 1000 }).map((x, i) => i)
@midudev
midudev / README.md
Created October 15, 2022 17:52
Transcribe vídeo de YouTube con Whisper e Inteligencia Artificial

Requisitos

Necesitas tener instalado Python 3.9 e instalar la dependencia de Whisper y PyTube:

pip install git+https://github.com/openai/whisper.git
pip install pytube

También necesitas tener instalado ffmpeg. Según tu sistema operativo se instala de esta forma:

@midudev
midudev / from-querystring-to-object.js
Created April 2, 2020 10:27
Transform from querystring to object
// get the querystring from document object
const qs = document.location.search
// create searchParams object
const searchParams = new URLSearchParams(qs)
// create a plain object using entries
const queryParamsObject = Object.fromEntries(searchParams.entries())
console.log(queryParamsObject)
@midudev
midudev / useLegacyState.js
Created June 17, 2019 10:46
quick'n'dirty state replacement that emulates the general behaviour of the old setState
// hook to emulate legacy state behaviour
const useLegacyState = (initialState = {}) => {
const [state, setState] = useState(initialState)
function setLegacyState (partialNewState) {
let newState = {...state}
if (typeof partialNewState === 'object' && partialNewState !== null) {
newState = {...newState, ...partialNewState}
}
@midudev
midudev / animations.sh
Last active January 12, 2021 17:47
Make your OSX great again
# sh ./animations.sh
# set keyboard repeat rate to 0, so instant
defaults write -g InitialKeyRepeat -int 10 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms)
# instant quick look animation
defaults write -g QLPanelAnimationDuration -float 0
# increase speed of animation when resizing window of Cocoa apps
@midudev
midudev / using_map_and_filter.js
Created October 7, 2016 17:47
Example about how to use reduce to map and filter an array with one iteration
const MULTIMEDIA_IMAGE_TYPE_ID = 12
const multimedias = [
{ mediumSizeUrl: 'dog.jpg', typeId: 2 },
{ mediumSizeUrl: 'panda.jpg', typeId: 12 },
{ mediumSizeUrl: 'koala.jpg', typeId: 12 },
{ mediumSizeUrl: 'trex.jpg', typeId: 5 },
{ mediumSizeUrl: 'ratilla.jpg', typeId: 12 }
];
@midudev
midudev / testing_feedparser_ES6.js
Last active August 19, 2018 06:31
Example of using feedparser (https://github.com/danmactough/node-feedparser) with ES6 on node.js >= 4.0.0
'use strict'
const FeedParser = require('feedparser')
const request = require('request')
let req = request('https://github.com/danmactough.atom')
let parser = new FeedParser()
req.on('error', (err) => {
// handle request error
@midudev
midudev / 0_reuse_code.js
Created October 6, 2015 18:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@midudev
midudev / clearfix.styl
Last active December 20, 2015 11:09
Stylus mixin to do clearfix to an element.
clearfix()
&:after
content ""
display table
clear both
@midudev
midudev / index.html
Created July 3, 2013 15:10
A CodePen by Miguel. Which keycode is? - Discover which keycode is the key pressed. A simple script with pure JS to now the keyCode of the keyDown.
<body>
<a href="//miduga.es" title="Desarrollado por miduga para desarrolladores">Developed by miduga</a>
<div id="i">
Press a key<br/><span>And discover his keyCode to use it in your JavaScript projects.</span></div>
<div id="k"></div>