Created
November 20, 2013 00:44
-
-
Save saranrapjs/7555432 to your computer and use it in GitHub Desktop.
Code that generates the bot for https://twitter.com/NYCLLC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requires: sqlite3, ntwitter | |
var sqlite3 = require('sqlite3'), | |
db = new sqlite3.Database('biz.db'), | |
twitter = require('ntwitter'); | |
var twit = new twitter({ | |
consumer_key: 'all', | |
consumer_secret: 'your', | |
access_token_key: 'tokens', | |
access_token_secret: 'here' | |
}); | |
function tweet(msg, callback) { | |
twit.updateStatus(msg, | |
function (err, data) { | |
callback() | |
}); | |
} | |
function randomBiz(callback) { | |
db.get("SELECT * FROM biz ORDER BY RANDOM() LIMIT 1;",function(err,row) { | |
var biz = ''; | |
if (!err) biz = row['Current Entity Name'] + " " + row['Initial DOS Filing Date']; | |
console.log(biz) | |
callback(biz) | |
}); | |
} | |
(function run() { | |
randomBiz(function(biz) { | |
tweet(biz, function() { | |
// console.log("TWEETED?") | |
setTimeout(run, 1000*60*60*6) // every 3 hours? | |
}) | |
}) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To generate biz.db:
Download data from here: https://data.ny.gov/Economic-Development/Active-Corporations-Beginning-1800/n9v6-gdp6 (download as CSV)
Create schema in empty biz.db file
Import from downloaded csv (instructions here http://www.sqlite.org/cvstrac/wiki?p=ImportingFiles )
Filter to just the counties in New York City: