Skip to content

Instantly share code, notes, and snippets.

View camerican's full-sized avatar

Cam Crews camerican

View GitHub Profile
@camerican
camerican / topshot_lock_select_tampermonkey.js
Created August 2, 2022 01:58
Tampermonkey Script for TopShot Lock page Select All feature
// ==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
@camerican
camerican / topshot_lock_select.js
Last active August 2, 2022 02:02
Top Shot Locking Tool to Select All Moments
// 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
@camerican
camerican / mahima_oo.js
Created October 7, 2017 19:17
Mahima OO Code Review
//1.
function Multiplier(){
this.newValue = 1;
this.multiply = function(num){
this.newValue = (this.newValue * num);
return this.cValue; // cValue is undefined!!
}
this.getCurrentValue = function () {
@camerican
camerican / sherill_oo.js
Created October 7, 2017 19:06
Sherill OO Code Review
// 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 = [];
@camerican
camerican / valerie_oo_review.js
Created October 7, 2017 18:44
Valerie OO Code Review
// 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
@camerican
camerican / util.js
Created September 28, 2017 20:34
Utility functions
//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);
}
@camerican
camerican / calc.js
Last active October 12, 2016 15:22
Example of a simple function calculator w/ output to HTML Table
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);
});
@camerican
camerican / findBiSlice.rb
Created July 7, 2016 20:44
Determine the longest contiguous sub-array consisting of no more than two unique characters within an array
# 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
@camerican
camerican / array_intersection_benchmark.rb
Last active June 26, 2016 20:22
Array Intersection Solution Benchmarks
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)