Adafruit Order

From ATXHackerspace

Jump to: navigation, search

Adafruit Wholesale Order

We get various discounts from Adafruit if we order $250 worth of stuff. It's the Adafruit wholesale discount! So, if you want to get in on an order, add your request to this page. When the total gets to be ~$250, the order goes in, and is delivered to the hackerspace.

There have been various non-paying people on the last couple orders. SO, in order to put the order in this time, when the order is complete we'll be taking the payments BEFORE placing the order. Sorry, but the hackerspace just can't absorb $70-100 in unpaid items.

If there are any major items that are marked OUT OF STOCK the order will not be placed until either 1) the rest of the order totals more than $250 or 2) the major items come back into stock .. usually 5-7 days.

September 2013 Adafruit Order is OPEN

9999 Example Item 1 $1.00 $1.00 $1.00 Martin Bogomolni
SHIPPING UPS 2nd Day   $??.??   $??.??  

0% of $250 goal

Adding it up

Mostly you can add it up your total in your head or with a calculator just as quickly as copy/pasting this, but you can also use some tools to help.

Copy/paste + awk

Copy/paste the table from your web browser into a text file. You should get tab delimited output (tested using Google Chrome pasting into vim). Save the text file as "order.tsv" and run:

 awk -F"\t" '/YOURNAMEHERE/ {print $6}' order.tsv | tr -d '~$ '| awk '{sum+=$1}END{print sum}'

screen scraping with lynx and grep

This avoids the copy/paste, but requires that your name not appear on any other lines in this page.

  lynx -width=500 -dump "" | egrep -o "[0-9\.]*[0-9]*[ ]+YOURNAMEHERE" | awk '{sum+=$1}END{print sum}'

Here's one for elinks, which uses a vertical pipe and variable whitespace when rendering table cells:

  elinks --dump-width 500 -dump "" | egrep -o "[0-9\.]*[0-9]*[ ]+\|[ ]*YOURNAMEHERE" | awk '{sum+=$1}END{print sum}'

Built-in browser javascript console sniffing via DOM

You can open a javsacript console in Google Chrome or Firefox with Firebug installed by pressing the F12 key. Then paste in:

  var NAME_REGEXP=/YOURNAMEHERE/;var t = document.getElementById("orderTable");var sum=0;for( var i =0; i < t.rows.length ; ++i){var r = t.rows[i]; if( NAME_REGEXP.test(r.cells[6].textContent) ) { sum+= parseFloat( r.cells[5].textContent.replace(/[^\d\.]/g,'' ), 10); } };console.log( NAME_REGEXP.source + " owes: $" + sum );

Floating point rounding errors can happen due to IEEE 754 float representation in javscript. You'd have to convert dollars to cents to fix.