Full Code of bhberson/pizzadash for AI

master cb841a1cf860 cached
7 files
9.0 KB
2.5k tokens
1 symbols
1 requests
Download .txt
Repository: bhberson/pizzadash
Branch: master
Commit: cb841a1cf860
Files: 7
Total size: 9.0 KB

Directory structure:
gitextract_kjfd6soz/

├── .gitignore
├── LICENSE
├── README.md
├── app.js
├── exampleorder.json
├── findStore.js
└── package.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

**/.DS_Store

# ignore the order files,
*.json
# except exampleorder.json
!exampleorder.json
!package.json


================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2015 Brody Berson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



================================================
FILE: README.md
================================================
![Pizza Dash](http://i.imgur.com/DD944Cz.jpg)
PizzaDash
====
[![Join the chat at https://gitter.im/bhberson/pizzadash](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bhberson/pizzadash?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

This is a node.js application that "hacks" your [Amazon Dash Button](http://www.amazon.com/dashbutton) to order you a [Domino](https://www.dominos.com/)'s pizza!
I was inspired by [this article by Edward Bensen](https://medium.com/@edwardbenson/how-i-hacked-amazon-s-5-wifi-button-to-track-baby-data-794214b0bdd8).
I am using a few npm modules to listen for the button press and place the order: [RIAEvangelist](https://github.com/RIAEvangelist)'s [dominos](https://github.com/RIAEvangelist/node-dominos-pizza-api) and also [hortinstein](https://github.com/hortinstein)'s [Node-Dash-Button](https://github.com/hortinstein/node-dash-button).

One idea would be to have this [always running](#always-running) via a local server such as a Raspberry Pi and have on demand pizza ordering whenever you just need a pizza!

I wrote a blog post about my experience here on [Medium](https://medium.com/@brody_berson/hacking-amazon-s-5-dash-button-to-order-domino-s-pizza-9d19c9d04646)!

Requirements
====
__pcap__
If you are running ubuntu you will need to run ` sudo apt-get install libpcap0.8-dev `

Contributing
====

1. Pull or Fork code.
2. Do cool stuff.
3. Submit a PR.

Setup/Run
====
1. Run ` npm install ` the first time so all npm requirements will be installed.
2. Find Closest Store
  - Run ` node findStore.js ` and input your 5 digit zipcode, this will return closest store info (Store ID) and their menu.
3. Find Dash Button
  - Run ` sudo node node_modules/node-dash-button/bin/findbutton ` and press the button
4. Create your ` order.json ` file by copying ` exampleorder.json `
  - Add your store from step 2
  - Edit your address and personal/customer information
  - Edit your order using menu from step 2
  - Add credit card information
  - Add your Amazon Dash Button's address from step 3
5. Run` npm start ` and press your Dash Button that you have set up and BAM pizza will be coming soon!

Issues
====
If you run into any issues with Socket Watcher please try this: Looks like socketwatcher was using the legacy "node" command instead of nodejs. It is solved on ubuntu by installing nodejs-legacy that clears up those conflicts.
`sudo apt-get install nodejs-legacy`


Always Running
----
This [article](http://weworkweplay.com/play/raspberry-pi-nodejs/) shows you what you can do with a [Raspberry Pi](https://www.raspberrypi.org/) to set this up as a node server running all the time on your network and it literally would be the press of a button *whenever* you wanted!

Or you can view this [Gist](https://gist.github.com/bhberson/7a2847888596e67fd69b) to view how to create an AWS Lambda function if you own an Amazon AWS IoT Button. They basically handle the "always on" use case for us!

To do
----
- Create a Web Interface to assist in creating orders easily.
- Other ideas?


================================================
FILE: app.js
================================================
var dash_button = require('node-dash-button');
var pizzapi = require('dominos');
var orderconfig = require('./order.json');

//Input order from json
console.log("Getting order from file...");
var order = new pizzapi.Order(
  orderconfig["order"]
);
//Add items to order
console.log("Adding items to order...")
var items = orderconfig["items"];
for (var i=0; i<items.length; i++) {
  order.addItem(
    new pizzapi.Item(
      items[i]
    )
  );
}

// Setup your Credit Card Info
console.log("Setting up credit card info...")
var cardInfo = new order.PaymentObject();
cardInfo.Amount = order.Amounts.Customer;
cardInfo.Number = orderconfig["cardNum"];
cardInfo.CardType = order.validateCC(orderconfig["cardNum"]);
cardInfo.Expiration = orderconfig["cardExp"];//  01/15 just the numbers "01/15".replace(/\D/g,'');
cardInfo.SecurityCode = orderconfig["cardSec"];
cardInfo.PostalCode = orderconfig["cardPost"]; // Billing Zipcode

console.log("Adding card to order...");
order.Payments.push(cardInfo);

//TODO: if no mac address, find one and save it
console.log("Searching for Dash Button...");
var dash = dash_button(orderconfig["dashMacAddress"]);
dash.on("detected", function (){
    console.log("Dash Button Found");
    console.log("Configuring Dash Button...");
	//Validate, price, and place order!
	order.validate(
	    function(result) {
	        console.log("Order is Validated");
	    }
	);
	order.price(
	    function(result) {
            console.log("Order is Priced");
	    }
	);
	order.place(
	    function(result) {
            console.log("Price is", result.result.Order.Amounts, "\nEstimated Wait Time",result.result.Order.EstimatedWaitMinutes, "minutes");
	        console.log("Order placed!");
	    }
	);
	console.log("Listening...");
});

================================================
FILE: exampleorder.json
================================================
{
  "order":{
    "customer":{
      "firstName":"John",
      "lastName":"Smith",
      "address":{
        "Street": "JohnSmith Lane",
        "City": "JohnSmithville",
        "Region": "NY",
        "PostalCode": "90210"
      },
      "email":"johnsmith@johnsmith.gov",
      "phone":"15181231234"
    },
    "storeID":3302,
    "deliveryMethod":"Delivery"
  },
  "items":[
    {
      "code":"P_14SCREEN",
      "options":{},
      "quantity":1
    }
  ],
  "cardNum":4100123422343234,
  "cardExp":"0115",
  "cardSec":777,
  "cardPost":90210,
  "dashMacAddress":"ff:ff:ff:ff:ff:ff"
}


================================================
FILE: findStore.js
================================================
var pizzapi = require('dominos');
var prompt = require('prompt');

var myStore;

prompt.start();

prompt.get(['zip'], function (err, result) {
    if (err) { return onErr(err); }
    //Get stores by postal code, distance is not as accurate this way
    pizzapi.Util.findNearbyStores(
        result.zip,
        'Delivery',
        function(storeData) {
            myStore = new pizzapi.Store(
                {
                    ID: storeData.result.Stores[0].StoreID
                }
            );

            //Get Info for first store
            myStore.getInfo(
                function(storeData) {
                    console.log('\n\n##################\nClosest Store Info\n##################\n\n',storeData.result);
                }
            );
            //Get Menu for first store
            myStore.getFriendlyNames(
                function(storeData) {
                    console.log('\n\n##################\nClosest Store Menu\n##################\n\n',storeData.result);
                }
            );
        }
    );
});

function onErr(err) {
    console.log(err);
    return 1;
}

================================================
FILE: package.json
================================================
{
  "name": "pizzadash",
  "version": "1.0.0",
  "description": "Order Pizza with Amazon Dash Button",
  "main": "app.js",
  "dependencies": {
    "node-dash-button": "^0.4.0",
    "dominos": "^2.0.1",
    "prompt": "^1.0.0"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "sudo node app.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://bhberson@github.com/bhberson/pizzadash.git"
  },
  "keywords": [
    "Dominos",
    "Domino's",
    "Pizza",
    "API",
    "Pie",
    "PizzaPI",
    "Amazon",
    "AmazonDash",
    "Dash",
    "Button"
  ],
  "author": {
    "name": "Brody Berson",
    "email": "brody.berson@gmail.com",
    "url": "http://www.brodyberson.com"
  },
  "contributors": [
    {
      "name": "Brandon Miller",
      "email": "brandon@diginow.it",
      "url": "http://www.diginow.it"
    },
    {
      "name": "Joseph Iaquinto",
      "email": "iaquinto.joe@gmail.com",
      "url": "http://joeiaquinto.github.io/"
    },
    {
      "name": "Dan Gorman",
      "email": "danthemangorman@gmail.com",
      "url": "http://dangothemango.github.io/"
    }
  ],
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/bhberson/pizzadash/issues"
  },
  "homepage": "https://github.com/bhberson/pizzadash#readme"
}
Download .txt
gitextract_kjfd6soz/

├── .gitignore
├── LICENSE
├── README.md
├── app.js
├── exampleorder.json
├── findStore.js
└── package.json
Download .txt
SYMBOL INDEX (1 symbols across 1 files)

FILE: findStore.js
  function onErr (line 37) | function onErr(err) {
Condensed preview — 7 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (10K chars).
[
  {
    "path": ".gitignore",
    "chars": 237,
    "preview": "# Dependency directory\n# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git\nnode"
  },
  {
    "path": "LICENSE",
    "chars": 1080,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2015 Brody Berson\n\nPermission is hereby granted, free of charge, to any person obta"
  },
  {
    "path": "README.md",
    "chars": 3074,
    "preview": "![Pizza Dash](http://i.imgur.com/DD944Cz.jpg)\nPizzaDash\n====\n[![Join the chat at https://gitter.im/bhberson/pizzadash](h"
  },
  {
    "path": "app.js",
    "chars": 1756,
    "preview": "var dash_button = require('node-dash-button');\nvar pizzapi = require('dominos');\nvar orderconfig = require('./order.json"
  },
  {
    "path": "exampleorder.json",
    "chars": 590,
    "preview": "{\n  \"order\":{\n    \"customer\":{\n      \"firstName\":\"John\",\n      \"lastName\":\"Smith\",\n      \"address\":{\n        \"Street\": \""
  },
  {
    "path": "findStore.js",
    "chars": 1114,
    "preview": "var pizzapi = require('dominos');\nvar prompt = require('prompt');\n\nvar myStore;\n\nprompt.start();\n\nprompt.get(['zip'], fu"
  },
  {
    "path": "package.json",
    "chars": 1326,
    "preview": "{\n  \"name\": \"pizzadash\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Order Pizza with Amazon Dash Button\",\n  \"main\": \"app.js"
  }
]

About this extraction

This page contains the full source code of the bhberson/pizzadash GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 7 files (9.0 KB), approximately 2.5k tokens, and a symbol index with 1 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!