Skip to content

Instantly share code, notes, and snippets.

View ismaelc's full-sized avatar

Chris Ismael ismaelc

View GitHub Profile
@ismaelc
ismaelc / MashapeNodejs.js
Created November 18, 2012 05:44
Nodejs example to access Mashape APIs using REST
var querystring = require('querystring');
var https = require('https');
// Set up Mashape stuff
var options = {
host: 'ismaelc-bitly.p.mashape.com',
port: 443,
path: '/v3/shorten/',
method: 'POST', // Using POST instead of GET, to please post_data below
headers: {
@ismaelc
ismaelc / mashapeandroidsnippet.java
Last active October 13, 2015 18:57
Mashape Android Async example
public void sendMessage(View view) {
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
new CallMashapeAsync().execute(message);
}
@ismaelc
ismaelc / FaceRecognitionMashapeSample.js
Last active December 15, 2015 02:58
Face Recognition API using photobooth.js
$(document).ready(function () {
var file = null;
$('#photo').photobooth().on("image", function (event, dataUrl) {
file = dataURLtoBlob(dataUrl);
var size = file.size;
alert("Picture size: " + size);
uploadImage(file);
$("#gallery").append('<img src="' + dataUrl + '" >');
});
});
@ismaelc
ismaelc / FaceRecognitionMashapeResponseSample.json
Created March 19, 2013 00:09
Face Recognition Mashape JSON response
{
“status”: “success”,
“images”: [
“http://lambdal.com/tiger.jpg”
],
“photos”: [
{
“url”: “http://lambdal.com/tiger.jpg”,
“width”: 600,
“tags”: [
@ismaelc
ismaelc / YactraqResponse.js
Created April 3, 2013 22:07
This is an example response for the Yactraq Mashape API to do topic extraction and transcription of videos.
{
"status": "processed",
"topics": [
{
"complete": false,
"ts": 60.04,
"topics": [
"phones best",
"best top phones",
"droid"
@ismaelc
ismaelc / YactraqMashapeTranscription.js
Created April 3, 2013 22:39
Yactraq Mashape Transcription Results
"transcript": [
{
"w": "thanked",
"p": 0.087,
"ts": 0.02
},
{
"w": "never",
"p": 1,
"ts": 0.67
@ismaelc
ismaelc / summarize.py
Created April 30, 2013 19:37
Summarize algorithm adapted for Flask and PythonAnywhere (based from http://thetokenizer.com/2013/04/28/build-your-own-summary-tool/)
# coding=UTF-8
from __future__ import division
import re, urllib2
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello from Flask!'
HttpResponse<string> jsonResponse = Unirest.get("https://yoda.p.mashape.com/yoda?sentence=You%20will%20learn%20how%20to%20speak%20like%20me%20someday.%20%20Oh%20wait.");
.header("X-Mashape-Authorization", "<Get your own Mashape key and paste it here>")
.asJson<string>();
textBlock1.Text = jsonResponse.Body;
@ismaelc
ismaelc / receiveTwilioSMS.js
Created June 8, 2013 00:12
node.js snippet showing SMS being received from Twilio. Full source code is at https://github.com/ismaelc/twilio-translator
exports.receiveSMS = function (req, res) {
//TODO: Check if call is coming from Twilio
var message = req.body.Body;
var from = req.body.From;
var to = req.body.To;
...
}
@ismaelc
ismaelc / callPhoneFromTwilio.js
Created June 8, 2013 00:33
node.js function snippet showing a REST API call to Twilio to call a phone. Full source code is at https://github.com/ismaelc/twilio-translator
// Builds the call request so Twilio can call the user's phone with the local voice of the translation, using a text to speech API
exports.makeCall = function (req, res) {
// TODO: Check if function is called from same app
var translatedText = req.query.t;
var to = req.query.to;
var lang = req.query.lang;
// The parameters needed by Twilio to make the call. The Url parameter returns a Twiml that dictates what happens when
// the call is picked up.
var postdata = qs.stringify({