This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WAV to MP3 | |
ffmpeg -i origin.wav -c:a libmp3lame -q:a 7 destination.mp3 | |
# WAV to M4A (96k constant bitrate) | |
ffmpeg -i origin.wav -c:a libfdk_aac -b:a 96k destination.m4a | |
# WAV to M4A (variable bitrate) | |
ffmpeg -i origin.wav -c:a libfdk_aac -vbr 3 destination.m4a | |
# Add -ac 1 for mixdown to mono |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const array = [ | |
{ id: 1 }, | |
{ id: 2 }, | |
{ id: 3 }, | |
{ id: 4, children: [ | |
{ id: 6 }, | |
{ id: 7, children: [ | |
{ id: 8 }, | |
{ id: 9 } | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const removeDuplicates = (arr) => [...new Set(arr)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const groupBy = (arr, groupFn) => arr.reduce((grouped, obj) => ({...grouped,[groupFn(obj)]: [...(grouped[groupFn(obj)] || []), obj], }), {}); | |
// Using it | |
const people = [ | |
{ name: 'Matt' }, | |
{ name: 'Sam' }, | |
{ name: 'John' }, | |
{ name: 'Mac' }, | |
]; | |
groupBy(people, (person) => person.name.length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getLargestElement = (arr) => arr.reduce((largest, num) => Math.max(largest, num)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getSmallestElement = (arr) => arr.reduce((smallest, num) => Math.min(smallest, num)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.bg-video { | |
position: fixed; | |
z-index: -1; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
} | |
@media (min-aspect-ratio: 16/9) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original gist | |
const shuffleArray = arr => arr.sort(() => Math.random() - 0.5); | |
// Fully random by @BetonMAN | |
const shuffleArray = arr => arr.map(a => [Math.random(), a]).sort((a, b) => a[0] - b[0]).map(a => a[1]); | |
// Fisher-Yates shuffle one-liner | |
const shuffleArray = (arr) => [...Array(arr.length)].map((_, i) => Math.floor(Math.random() * (i + 1))).reduce((shuffled, r, i) => shuffled.map((num, j) => j === i ? shuffled[r] : j === r ? shuffled[i] : num),arr); |