<commit_before>request = require 'request'
Twitter = require 'simple-twitter'
config = require './config'
twitter = new Twitter(config.twitter.consumerKey,config.twitter.consumerSecret,config.twitter.token,config.twitter.tokenSecret)
params = 
	qs:
		api_key:config.key
	url : 'http://realtime.mbta.com/developer/api/v1/alerts'
	json:true

dcb = (err)->
	console.log(err)

cleanForTweet=(msg)->
	if msg.length > 132
		msg = msg.slice(0,132)+'...'
	msg = msg+' #mbta'
	msg.replace /\b\w+?\b Line/g,(a)->
		'#'+a.replace(/\ /,"")
	
tweet = (msg,cb=dcb)->
	twitter.post('statuses/update',{status:cleanForTweet(msg)},cb)

i = 0
eachAlert = (v)->
	v['_id']=v['alert_id'].toString()
	nParams = 
		url:"https://#{config.couch}@calvin.iriscouch.com/mbta/#{v._id}"
		json:true
	request nParams,(e,r,b)->
		if r.statusCode == 200
			v._rev=b._rev
			nParams.method='put'
		else
			console.log 'tweeting ',v.header_text 
			tweet v.header_text
			nParams.method='post'
			nParams.url = "https://#{config.couch}@calvin.iriscouch.com/mbta"
		nParams.body=v
		request nParams,(e,r,b)->
			true
		true
	true
start = ()->
	console.log 'running it time ', ++i
	request params, (e,r,b)->
		b.alerts.forEach eachAlert
		true<commit_msg>don't hard code the server<commit_after>request = require 'request'
Twitter = require 'simple-twitter'
config = require './config'
twitter = new Twitter(config.twitter.consumerKey,config.twitter.consumerSecret,config.twitter.token,config.twitter.tokenSecret)
params = 
	qs:
		api_key:config.key
	url : 'http://realtime.mbta.com/developer/api/v1/alerts'
	json:true

dcb = (err)->
	console.log(err)

cleanForTweet=(msg)->
	if msg.length > 132
		msg = msg.slice(0,132)+'...'
	msg = msg+' #mbta'
	msg.replace /\b\w+?\b Line/g,(a)->
		'#'+a.replace(/\ /,"")
	
tweet = (msg,cb=dcb)->
	twitter.post('statuses/update',{status:cleanForTweet(msg)},cb)

i = 0
eachAlert = (v)->
	v['_id']=v['alert_id'].toString()
	nParams = 
		url:"https://#{config.couch.user}:#{config.couch.pw}@#{config.couch.server}/#{config.couch.db}/#{v._id}"
		json:true
	request nParams,(e,r,b)->
		if r.statusCode == 200
			v._rev=b._rev
			nParams.method='put'
		else
			console.log 'tweeting ',v.header_text 
			tweet v.header_text
			nParams.method='post'
			nParams.url = "https://#{config.couch.user}:#{config.couch.pw}@#{config.couch.server}/#{config.couch.db}"
		nParams.body=v
		request nParams,(e,r,b)->
			true
		true
	true
start = ()->
	console.log 'running it time ', ++i
	request params, (e,r,b)->
		if b and b.alerts
			b.alerts.forEach eachAlert
		else
			console.log e,r,b
		true
{'fraction_non_alphanumeric': 0.19448757763975155, 'fraction_numerical': 0.009316770186335404, 'mean_word_length': 4.033203125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '595583', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1024, 'n_words': 168}