Skip to content

Instantly share code, notes, and snippets.

View brynnb's full-sized avatar

Brynn brynnb

View GitHub Profile
@brynnb
brynnb / amazingpriceperunitsort.js
Created May 21, 2024 15:07
This bookmarklet allows you to rearrange Amazon search results by the lowest to highest price per unit of measure. It extracts price and unit information from each search result, standardizes units to milliliters, calculates the price per milliliter, and then reorders the items accordingly.
javascript:(function(){function convertToMilliliters(value,unit){switch(unit.toLowerCase()){case 'fl oz':case 'fl. oz':return value*29.5735;case 'oz':return value*29.5735;case 'ml':return value;case 'l':return value*1000;default:console.warn(`Unrecognized unit: ${unit}`);return null;}}function parsePriceAndUnit(element){console.log('Parsing price and unit from element:', element);let priceText=element.querySelector('.a-offscreen').textContent.replace(/[^0-9.]/g,'');let match=element.textContent.match(/\/([a-zA-Z\s.]+)/);console.log(priceText,match);if(!match){console.warn('No unit match found in element:', element);return null;}let unitText=match[1].trim();return{price:parseFloat(priceText),unit:unitText};}var pricePerUnitElements=document.querySelectorAll('[class*="a-price a-text-price"]');var items=[];pricePerUnitElements.forEach(el=>{let parentContainer=el.closest('[data-component-type="s-search-result"]');if(parentContainer){let priceAndUnitParent=el.closest('.a-size-base.a-color-secondary');if(priceAndUn
var express = require('express');
var fs = require('fs');
var app = express();
var bodyParser = require("body-parser");
var server = require('http').Server(app);
var mongo = require('mongodb').MongoClient;
var ObjectId = require('mongodb').ObjectID;
var io = require('socket.io').listen(server);
var nodemailer = require('nodemailer');
var utils = require('./utils'),
glob = require('glob'),
async = require('async'),
fileLib = require("node-fs"),
path = require('path'),
_ = require('lodash'),
fs = require('fs'),
mkdirp = require('mkdirp');
var basePath = process.cwd(),
@brynnb
brynnb / installbqdev.sh
Created September 17, 2012 00:34
Installing BrowserQuest (Dev Build) on fresh EC2 Install (Ubuntu 12 x64)
apt-get update
apt-get upgrade
apt-get install -y curl build-essential pkg-config bison git npm nodejs
git clone https://github.com/browserquest/BrowserQuest.git
npm install underscore log bison websocket websocket-server sanitizer memcache
cd BrowserQuest/client
npm install -g http-server
@brynnb
brynnb / installbq.sh
Created September 16, 2012 22:50
Installing BrowserQuest on fresh EC2 Install (Ubuntu 12 x64)
apt-get update
apt-get upgrade
apt-get install -y curl build-essential pkg-config bison git npm nodejs
git clone https://github.com/brynnb/BrowserQuest.git
npm install underscore log bison websocket websocket-server sanitizer memcache
cd BrowserQuest/client
npm install -g http-server
@brynnb
brynnb / missingBQmusic.sh
Created September 16, 2012 22:36
Pulling in the missing music files for BrowserQuest
wget http://browserquest.mozilla.org/audio/music/village.mp3
wget http://browserquest.mozilla.org/audio/music/beach.mp3
wget http://browserquest.mozilla.org/audio/music/forest.mp3
wget http://browserquest.mozilla.org/audio/music/cave.mp3
wget http://browserquest.mozilla.org/audio/music/desert.mp3
wget http://browserquest.mozilla.org/audio/music/lavaland.mp3
wget http://browserquest.mozilla.org/audio/music/boss.mp3
wget http://browserquest.mozilla.org/audio/music/village.ogg
wget http://browserquest.mozilla.org/audio/music/beach.ogg
wget http://browserquest.mozilla.org/audio/music/forest.ogg