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
// ==UserScript== | |
// @name TopShot Locking Page Enhancements | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Add the ability to select multiple moments to the Top Shot lock page | |
// @author Camerican | |
// @match https://nbatopshot.com/lock* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// @require http://code.jquery.com/jquery-latest.js |
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
// About - This script enables you to Select All Top Shot moments from the https://nbatopshot.com/lock page | |
// At the time of writing, you had to select moments one by one, which is a pain in the arse | |
// You can alternatively use a version of this script that works with Chrome browser extension Tampermonkey: | |
// | |
// https://gist.github.com/camerican/aeee6f0ff6e3d43e419047365cb2e2dc | |
// | |
// The Tampermonkey version of this script at the link above adds "Select All" and "Deselect All" buttons | |
// to the NBA TopShot lock page, which makes use of the script more intuitive | |
// | |
// Author - Camerican 8/1/22 |
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
//1. | |
function Multiplier(){ | |
this.newValue = 1; | |
this.multiply = function(num){ | |
this.newValue = (this.newValue * num); | |
return this.cValue; // cValue is undefined!! | |
} | |
this.getCurrentValue = function () { |
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
// Create a prototypical Person object. | |
// From this object, | |
// --> Extend a Teacher object and a Student object. | |
// --> Each of these objects should have attributes and methods pertinent to what they describe. | |
// --> Also create a School object that should be able to store instances of students and teachers. | |
// --> Make sure to write code afterwards that creates instances of these objects to make sure that what you’ve written works well and you’re able to store the necessary data in each object. | |
function School(){ | |
this.class = []; |
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
// This is the beginning of the code for #1 | |
function Multiplier() { | |
// declaring a method within the constructor generally isn't as desirable as | |
// declaring it on the prototype of the constructor (that way all instances use the prototype | |
// method rather than getting their own copy of the method) | |
this.multiply = function(){ | |
// in here you'd want to change the value of a currentValue rather than simply log out the number 0 | |
console.log(' ' * 1); // ' ' space character is converted to 0 and multiplied by 1, which is 0 |
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
//convert duration from milliseconds to human-readable Minute:SS display: | |
function convertDuration(duration){ | |
let seconds = Math.ceil(duration / 1000); | |
return parseInt(seconds/60) + ":" + ("0"+seconds%60).slice(-2); | |
} |
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
let elM, elC, elP, elR, points; | |
let min = -10 | |
let max = 10; | |
document.addEventListener("DOMContentLoaded",function(){ | |
elM = document.getElementById("m"); | |
elC = document.getElementById("c"); | |
elP = document.getElementById("p"); | |
elR = document.getElementById("result"); | |
document.getElementById("run").addEventListener("click",calculate); | |
}); |
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
# Determine the longest contiguous sub-array consisting of | |
# no more than two unique characters within an array | |
# | |
# @author Cam Crews | |
# @see https://codefights.com/challenge/n75eG9MuhDzejuCyp/main | |
# | |
# @param a [Array] array to scan | |
# @return [Integer] length of subarray | |
def findBiSlice a | |
# q - queue, our current scan region |
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
require 'benchmark' | |
def cary array1, array2 | |
(array1 & array2).flat_map { |n| [n]*[array1.count(n), array2.count(n)].min } | |
end | |
def cary2 array1, array2 | |
cnt1 = cnt(array1) | |
cnt2 = cnt(array2) |