This file contains hidden or 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
// ==UserScript== | |
// @name Litmos speed controls | |
// @namespace rodrigo.deodoro@carta.com | |
// @version 0.2 | |
// @description Add speed controls to SAP Litmos videos | |
// @author Rodrigo Deodoro | |
// @match https://*.litmos.com/course/* | |
// ==/UserScript== | |
(function () { |
This file contains hidden or 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 input = [1,3,5,7]; | |
function product(inputArr) { | |
const resultArr = new Array(inputArr.length); | |
let product = 1; | |
for(let i = 0; i < inputArr.length; i++) { | |
product *= inputArr[i]; | |
if (i+1 < inputArr.length) { |
This file contains hidden or 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 input = [1,3,5,7]; | |
function product(inputArr) { | |
const productMap = new Map(); | |
const resultArr = []; | |
let product = 1; | |
for(let i = 0; i < inputArr.length; i++) { | |
product *= inputArr[i]; | |
productMap.set(i+1, product); |
This file contains hidden or 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 input = [1,3,5,7]; | |
function product(inputArr) { | |
const beforeMap = new Map(); | |
const afterMap = new Map(); | |
const resultArr = []; | |
let product = 1; | |
let reverseProduct = 1; |
This file contains hidden or 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 input = [1,3,5,7]; | |
function product(inputArr) { | |
const output = []; | |
for (let i = 0; i < inputArr.length; i++) { | |
let product = 1; | |
for (let j = 0; j < inputArr.length; j++) { | |
if (i !== j) { | |
product *= inputArr[j]; |
This file contains hidden or 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 input = [1,3,5,7]; | |
const fn = (inputArr) => | |
inputArr | |
.map(x => [...inputArr]) | |
.map((x, i) => { | |
const firstPart = x.slice(0, i); | |
const lastPart = x.slice(i+1); | |
return [...firstPart, ...lastPart]; |
This file contains hidden or 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
/** | |
* A slightly different approach that uses different methods to achieve the same result. Just for fun ;) | |
*/ | |
const input = [1,3,5,7]; | |
const fn2 = (inputArr) => { | |
return new Array(inputArr.length) | |
.fill(null) | |
.map(x => [...inputArr]) // if elems in inputArr are not primitive, you will need to deep-copy for the next step |
This file contains hidden or 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
# Require the gems | |
require 'capybara/poltergeist' | |
require 'selenium-webdriver' | |
require 'json' | |
# Configure Poltergeist to not blow up on websites with js errors | |
Capybara.register_driver :poltergeist do |app| | |
Capybara::Poltergeist::Driver.new(app, js_errors: false) | |
end |