Skip to content

Instantly share code, notes, and snippets.

@devStepsize
devStepsize / alchemy_api_get_keywords_url.py
Created May 5, 2016 18:29
Get identified keywords from a webpage using AlchemyAPI
import requests
endpoint = "http://gateway-a.watsonplatform.net/calls/url/URLGetRankedKeywords"
parameters = {
'apikey': API_KEY,
'outputMode': 'json',
'url': 'https://blog.vellumatlanta.com/2016/05/04/apple-stole-my-music-no-seriously/'
}
r = requests.get(endpoint, params=parameters)
@devStepsize
devStepsize / alchemyapi_clean_text.py
Created May 5, 2016 18:20
Get some cleaned text from a given webpage using AlchemyAPI.
import requests
endpoint = "http://gateway-a.watsonplatform.net/calls/url/URLGetText"
parameters = {
'apikey': API_KEY,
'outputMode': 'json',
'url': 'http://techcrunch.com/'
}
r = requests.get(endpoint, params=parameters)
@devStepsize
devStepsize / alchemy_api_entity_extraction_url.py
Last active May 5, 2016 18:12
Extract entities from a given webpage with the AlchemyAPI by giving it a URL
import requests
endpoint = "http://gateway-a.watsonplatform.net/calls/url/URLGetRankedNamedEntities"
parameters = {
'apikey': API_KEY,
'outputMode': 'json',
'url': 'https://www.reddit.com/'
}
r = requests.get(endpoint, params=parameters)
@devStepsize
devStepsize / alchemy_api_entity_extraction_text.py
Last active May 7, 2016 13:53
Extract entities from text using the AlchemyAPI
import requests
entities_endpoint = "http://gateway-a.watsonplatform.net/calls/text/TextGetRankedNamedEntities"
def get_entities(text):
data = {
'apikey': API_KEY,
'outputMode': 'json',
'text': text
}
headers = {'content-type': 'application/x-www-form-urlencoded'}
@devStepsize
devStepsize / clarifai_public_image_tagging.js
Last active May 5, 2016 17:08
Tag public images using Clarifai's Node.js client
// Sample code for clarifai-nodejs. From https://github.com/Clarifai/clarifai-nodejs/blob/master/clarifai_sample.js
var Clarifai = require('./clarifai_node.js');
Clarifai.initAPI(process.env.CLARIFAI_APP_ID, process.env.CLARIFAI_APP_SECRET);
// Setting a throttle handler lets you know when the service is unavailable because of throttling. It will let
// you know when the service is available again. Note that setting the throttle handler causes a timeout handler to
// be set that will prevent your process from existing normally until the timeout expires. If you want to exit fast
// on being throttled, don't set a handler and look for error results instead.
@devStepsize
devStepsize / clarifai_public_image_tagging.py
Last active May 5, 2016 16:23
Public image tagging with Clarifai's Python client
"""
Tagging a few public images from the web using the Clarifai API and the
clarifai-python client.
"""
from clarifai.client import ClarifaiApi
pictures = ['http://i.imgur.com/jJWlcnR.jpg', 'http://i.imgur.com/BflW5HQ.jpg']
@devStepsize
devStepsize / clarifai_local_image_tagging.py
Last active April 30, 2017 17:14
Local image tagging with Clarifai's Python client
"""
Tagging a few local images using the Clarifai API and the clarifai-python
client.
"""
from os.path import expanduser
from clarifai.client import ClarifaiApi
directory = expanduser('~/pictures/clarifai/')
hey matt
import whate
@devStepsize
devStepsize / ipcmain_on.js
Last active April 22, 2016 22:18
An example of receiving a message from the renderer process (in the main) for an electron app.
// In the main.js (main process)
ipcMain.on('hello from the webpage!', function(event, arg){
console.log('recieved!');
});
@devStepsize
devStepsize / ipcrenderer_send.js
Last active April 22, 2016 22:19
An example of a message being sent from the renderer process to the main process.
//In index.html (renderer process)
ipcRenderer.send('hello from the webpage!', 'my arg');