Skip to content

Instantly share code, notes, and snippets.

View haroldtreen's full-sized avatar

Harold Treen haroldtreen

View GitHub Profile
function getValues(line) {
return line.split(' ').map((i) => Number(i));
}
function processData(input) {
var lines = input.split('\n');
var inputValues = getValues(lines[0]);
var array = getValues(lines[1]);
fastest(inputValues[0], inputValues[1], array);
@haroldtreen
haroldtreen / hypem-bot.js
Created October 31, 2016 06:09
Easier downloading from hypem.com 🎵
(function() {
function getTracks() {
var tracks = [];
$('.section-player').each(function() {
tracks.push({
title: $(this).find('.track_name').text().replace(/\s+/g, ' ').trim() + '.mp3',
url: $(this).find('.dl').find('a').attr('href'),
});
});
return tracks;
@haroldtreen
haroldtreen / promise-test.js
Last active August 25, 2023 13:59
Testing promise rejection with Mocha
const { assert } = require('chai');
function isError(e) {
if (typeof e === 'string') {
return Promise.reject(new Error(e));
}
return Promise.resolve(e);
}