Tuesday, February 11, 2014

AutoCart Script - Sneaker Bot



Greetings Earthlings, I am a sneaker bot. I lurk deep within your browser; a behind the scenes master of stomping humanoid booty in the art of online shopping. I'm deceptive. I'm silent (when implemented right). I'm quick. I WIN. 




Mehhhhh. Maybe I talked myself up a bit, but I merely relay the facts. In short, I'm a simple script, packaged as a browser extension (Chrome in this case), that helps automate the process of selecting a shoe size, quantity, and hitting 'add to cart', specifically fashioned for use with sneaker purchases. I can be manually used on direct links, or I can also be directed from outside links such as twitter, search results, etc. etc. 


In order to be packaged as a chrome extension, I require a 'manifest.json' file. 


{
  "name": "sneaker_sniper_dood",
  "manifest_version": 2,
  "version": "1",
  "content_scripts": [
    {
      "matches": ["http://store.nike.com/*"],
      "js": ["autocart.js"]
    }
  ], "permissions": [
    "tabs", "http://store.nike.com/*"
  ]

}

An example of my contents are above. I'm a sneaker sniper dood. This files contains some required info for me to work. It also list the specific sites I'm built for, as well as points to the java script file (autocart.js in this case), that contains the bulk of my inner workings. More info on what all can be placed in the file can be found here: http://developer.chrome.com/extensions/manifest.html  

As for the bulk of my beauty (autocart.js), reference below:


var size = "10";
var amount = 2;

function addToCart() {
var sizesList=document.getElementsByName("skuAndSize")[0];
function setQuantity() {
   document.getElementsByName("qty")[0].selectedIndex = amount-1;
}
function setSizeValue() {
  for (var i=0; i
    if(sizesList.options[i].text == size) {
      document.getElementsByName("skuAndSize")[0].selectedIndex = i;
      setQuantity();
      }
   }
}
if(sizesList != undefined) {
  setSizeValue();
  document.getElementsByClassName("add-to-cart nsg-button--nike-orange")[0].click();
        else {
  setTimeout("addToCart()", 90);
}
}
setTimeout("addToCart()", 90);


The majority is simple functions that automate what a humanoid would do if they were selecting a size, a quantity to purchase, as well as clicking the 'add to cart' button. These functions may need a bit of periodic maintenance, but for the most part should work with ease. The only humanoid updates needed before my implementation would be an update to the size and amount variables.


Quick. Simple. Elegant. 

Want to see me in action. Yeah.... I thought so :)




Thursday, January 30, 2014

Excel Automation with VBA Macro

Got a request last week to help make someones life easier by turning a monotonous, multi-hour task, into an automated breeze. The input would be a list of names, as well as a list of selections, and the corresponding top 4 choices for each person from this selection base. This input table would be provided in .xlsx (Excel) format. 

The example below shows 5 sample students, as well as their top 4 choices from a list of companies. 




The objective of this task, would be to then take this input, and spit out an interview schedule for each student, across 4 30-minute time-slots. The schedules would also need to take into account the companies schedule as well, as there are only 4 time-slots available, and one company shouldn't be overloaded during a single slot, and underpopulated for other slots, etc. 

An example of the desired schedule output is reflected below. 





This highlights the 4 available time-slots, as well as each student, and their corresponding schedule based on their top 4 preferences. You can also see, that for some students, the companies don't go in order across the time-slots, as these were re-arrange to account for under/overloading a company during specific time-slots. 

A summary table for showing number of students per time-slot per company is also generated after schedule creation. 




Currently, 2 schedules are created using 2 different sorting methods to try and optimize the population per-slot for each company. Schedule2 has proved to be a more ideal output the majority of the time; however, in this early revision of the script, the optimization is still not perfect. 

As the input and output file were both desired to be in .xlsx (Excel) format, I decided to go the Excel macro route, rather than have extract the data in .csv to manipulate with an outside script (such as python, perl, etc), then have to feed back into Excel. 

The macro route allowed me to keep everything embedded in the actual .xlsx file, as well as limit the number of docs that needed to be maintained, etc. 

For a minimal number of student inputs, the schedule creation is rather trivial to do by hand; however, with the latest input expected to exceed >; 200 students, you can see how automation can save significant time. 


Currently, the script can churn through the 200 students in ~15seconds. A pretty significant amount of time-savings if you asked me. 

Anyways, I may write-up the nitty-gritty details later, but a small clip is available below. 















Tuesday, January 28, 2014

Cryptocurrency Fever - Mining Bitcoin / Dogecoin



So, I’ve recently began delving into mining cryptocurrency. As I’m new to the game, at this time I’ve spent more time researching opposed to actual mining. For the most part, I’ve missed the curve for the Godfather of crypto, BitCoin (BTC).
Currently the difficulty factor for this S.O.B far exceeds the capabilities of my current mining hardware. Assuming ~250KH/s with my current GPU, I would mine a dismal 0.00000174 BTC after 1 month of 24/7 operation. à No Bueno por Nada.



As such, I’ve been going down the trail of Dogecoin for the time being. This is a fairly new crypto and is mined via a different algorithm than BTC (scrypt vs. sha256). Due to the young age of this guy, the difficulty is substantially lower, and the reality of mining a good chuck of these suckers via CPU and/or GPU mining isn’t too far-fetched. At ~250KH/s with my current GPU, I can estimate ~2100 coins per day, or ~$3.30, not factoring in power cost, etc. But hey, should the value of the coin rise in the future, at least I’ll have a good little chuck saved up.

Well, I’ll post later on some additional details of getting up and running, as well as some free trail cloud servers that I’ve also setup some virtual machines and deployed some mining scripts in parallel there as well.