Skip to content

Instantly share code, notes, and snippets.

View jsloyer's full-sized avatar

Jeff Sloyer jsloyer

View GitHub Profile
private JSONArray cloudant;
private JSONObject cloudantInstance;
private JSONObject cloudantCredentials;
public CloudantClient()
{
this.httpClient = null;
try {
String VCAP_SERVICES = System.getenv("VCAP_SERVICES");
public CloudantClient()
{
this.httpClient = null;
//TODO read env VCAP_SERVICES and parse it into JSON
this.port = Config.CLOUDANT_PORT;
this.host = "";
this.username = "";
this.password = "";
this.name = Config.CLOUDANT_NAME;
private static JSONArray watson;
private static JSONObject watsonInstance;
private static JSONObject watsonCredentials;
private Executor executor;
public WatsonUserModeller()
{
try {
String VCAP_SERVICES = System.getenv("VCAP_SERVICES");
public WatsonUserModeller()
{
//TODO read env VCAP_SERVICES and parse it into JSON
this.username = "";
this.password = "";
this.base_url = "";
this.profile_api = Config.WATSON_PROF_API;
this.visual_api = Config.WATSON_VIZ_API;
this.executor = Executor.newInstance().auth(username, password);
if (this.executor == null)
@jsloyer
jsloyer / gist:c23878f6446aad2dfa40
Last active August 29, 2015 14:07
talent manager manifest.yml before
applications:
- disk_quota: 1024M
host: talent-manager
name: talent-manager
path: webStarterApp.war
domain: mybluemix.net
instances: 1
memory: 512M
@jsloyer
jsloyer / gist:b4df32b237d36e5dc901
Last active August 29, 2015 14:07
talent-manager manifest.yml after
applications:
- disk_quota: 1024M
host: talent-manager-awesome
name: talent-manager-awesome
path: webStarterApp.war
domain: mybluemix.net
instances: 1
memory: 512M
@jsloyer
jsloyer / gist:12f472bac138816d1f38
Created November 13, 2014 13:03
jazzhub deploy script before
cf push "${CF_APP}" -n "${CF_APP}-${CF_SPACE}"
# View logs
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]
then
cf logs "${CF_APP}" --recent
exit $EXIT_CODE
fi
@jsloyer
jsloyer / gist:5d68e5c36acaa2e05c0b
Last active August 29, 2015 14:09
jazzhub deploy script after
cf set-env "${CF_APP}" TWILIO_PHONENUMBER "replaceme"
cf set-env "${CF_APP}" TWILIO_SID "replaceme"
cf set-env "${CF_APP}" TWILIO_TOKEN "replaceme"
cf set-env "${CF_APP}" TWITTER_ACCESSTOKEN_KEY "replaceme"
cf set-env "${CF_APP}" TWITTER_ACCESSTOKEN_SECRET "replaceme"
cf set-env "${CF_APP}" TWITTER_CONSUMER_KEY "replaceme"
cf set-env "${CF_APP}" TWITTER_CONSUMER_SECRET "replaceme"
cf push "${CF_APP}" -c "node lib/app.js"
@jsloyer
jsloyer / watsonAndTwitter.js
Last active August 29, 2015 14:10
building an app watson and twitter code
function merge(defaults, options) {
defaults = defaults || {};
if (options && typeof options === 'object') {
var keys = Object.keys(options);
for (var i = 0, len = keys.length; i < len; i++) {
var k = keys[i];
if (options[k] !== undefined) defaults[k] = options[k];
}
}
return defaults;
app.post('/sms', function (request, response) {
var body = request.body.Body,
twitterHandles = [],
twitterId1,
twitterId2;
console.log("Twitter handles before replacing and splitting", body);
body = body.replace(/\@/g, "").replace(/and/g, "");
twitterHandles = body.split(/[ ,]+/);