Skip to content

Instantly share code, notes, and snippets.

View nhobi's full-sized avatar
🌼

Nate nhobi

🌼
View GitHub Profile
@nhobi
nhobi / keepIndexInBounds.js
Created May 6, 2021 22:50
A Vue mixin that handles keeping the index for a given collection in bounds.
export default (collectionName, indexName = "selectedIndex", cycle = false) => {
return {
watch: {
[indexName](newValue, oldValue) {
if (this[collectionName] === undefined) {
return;
}
let highestIndex = this[collectionName].length - 1;
@nhobi
nhobi / uploadBlob.js
Created May 6, 2021 22:56
Uploads a given blob to S3.
import random from "./randomString";
function getBucketObj() {
AWS.config.region = window.aws.region; // 1. Enter your region
AWS.config.credentials = new AWS.Credentials(aws.key, aws.secret);
AWS.config.credentials.get(function(err) {
if (err) alert(err);
});
@nhobi
nhobi / calculateDownloadSpeed.js
Last active May 6, 2021 22:59
Calculates the download speed of your current network based on an image fixture.
export default () => {
return new Promise((resolve, reject) => {
let imageAddr =
"https://nhmisc.s3.amazonaws.com/liswall/stub.jpg" +
"?n=" +
Math.random();
let startTime, endTime;
let downloadSize = 1025385;
let download = new Image();