Skip to content

Instantly share code, notes, and snippets.

View naveedn's full-sized avatar
🎯
Focusing

Naveed naveedn

🎯
Focusing
View GitHub Profile
@naveedn
naveedn / speedcontrols.user.js
Created October 6, 2020 16:56 — forked from roddds/speedcontrols.user.js
Add speed controls to SAP Litmos
// ==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 () {
@naveedn
naveedn / iterative_approach_4.js
Last active March 19, 2018 04:19
Medium Article Snippet
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) {
@naveedn
naveedn / iterative_approach_3.js
Created March 19, 2018 03:08
Medium Article Snippet
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);
@naveedn
naveedn / iterative_approach_2.js
Last active March 19, 2018 04:05
Medium Article Snippet
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;
@naveedn
naveedn / iterative_approach.js
Last active March 19, 2018 04:05
Medium Article Snippet
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];
@naveedn
naveedn / fp_approach.js
Last active March 19, 2018 04:08
Medium Article Snippet
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];
@naveedn
naveedn / fp_approach_2.js
Last active March 19, 2018 04:08
Medium Article Snippet
/**
* 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
@naveedn
naveedn / UMD_Orgsync_Web_Scraper
Created November 19, 2014 05:54
A simple scraper designed to get a list summary of every event that student organizations have posted to UMD's Orgsync platform.. because they won't allow access to their REST api
# 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