Skip to content

Instantly share code, notes, and snippets.

View germanattanasio's full-sized avatar
🇦🇷
Learning

German Attanasio germanattanasio

🇦🇷
Learning
View GitHub Profile
@germanattanasio
germanattanasio / .jslintrc
Created April 11, 2015 03:29
JSHint configuration for node development
{
"globals": {
"jasmine": false,
"spyOn": false,
"it": false,
"console": false,
"describe": true,
"expect": false,
"beforeEach": false,
"before": false,
@germanattanasio
germanattanasio / sh
Created July 20, 2015 21:37
Remove .DS_Store files
sudo find / -name ".DS_Store" -depth -exec rm {} \;
@germanattanasio
germanattanasio / create-classifier.js
Last active August 29, 2015 14:27
How to create a classifier using the nodejs wrapper
'use strict';
var watson = require('../nodejs-wrapper/lib/index');
var fs = require('fs');
var natural_language_classifier = watson.natural_language_classifier({
url: 'https://gateway.watsonplatform.net/natural-language-classifier/api',
username: 'USERNAME',
password: 'PASSWORD',
version: 'v1'
@germanattanasio
germanattanasio / AlchemyVision.js
Last active December 17, 2015 18:18
Example of how to call the AlchemyVision with the watson-developer-cloud npm module
// face recognition with a URL
var params = {
knowledgeGraph: 1 // Include knowledge graph information in the the results.
url: 'https://upload.wikimedia.org/wikipedia/commons/0/00/Scarlett_Johansson_-_Captain_America_2_press_conference_%28retouched%29_2.jpg'
};
// UNCOMMENT THE CODE BELOW TO SEND AN IMAGE INSTEAD OF A URL
// face recognition with an image
// var params = {
// image: fs.createReadStream('resources/face.jpg')
@germanattanasio
germanattanasio / ConversationExample.java
Created February 4, 2016 16:16
Dialog code snippet
// 1. Create the conversation
String message = "This is the first message";
Conversation conversation = new Conversation().workspaceId("dialog_id");
conversation = service.converse(message, conversation);
System.out.println(conversation);
// 2. Second message using the previous response
message = "This is the second message";
conversation = service.converse(message, conversation);
System.out.println(conversation);

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or

(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or

(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.

@germanattanasio
germanattanasio / visual-recognition-php-curl.php
Created March 27, 2016 18:29
Example of classifying an image using Visual Recognition in PHP
<?php
$data = ;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_POST => true,
CURLOPT_URL => "https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02",
CURLOPT_USERPWD => "USERNAME:PASSWORD",
CURLOPT_POSTFIELDS => array("images_file" => "@/path/to/your/image.png"),
@germanattanasio
germanattanasio / conversation-example.js
Created December 8, 2016 17:06
Conversation example that sends messages from the user to the Conversation API
var prompt = require('prompt-sync')();
var ConversationV1 = require('watson-developer-cloud/conversation/v1');
var conversation = new ConversationV1({
username: 'USERNAME',
password: 'PASSWORD',
path: { workspace_id: 'WORKSPACE_ID' },
version_date: '2016-07-11'
});
/**
@germanattanasio
germanattanasio / cleanupUnusedWorkspaceInSlaves.groovy
Created March 8, 2017 19:48 — forked from ceilfors/cleanupUnusedWorkspaceInSlaves.groovy
When you delete jobs in Jenkins, the corresponding workspaces in the build slaves won't be deleted automatically. This Jenkins script will go to each slave and check if the jobs are already deleted in Jenkins master and delete the workspace.
import com.cloudbees.hudson.plugins.folder.Folder
import hudson.FilePath
import jenkins.model.Jenkins
def boolean isFolder(String name) {
def item = Jenkins.instance.getItemByFullName(name)
return item instanceof Folder
}
def deleteUnusedWorkspace(FilePath root, String path) {
@germanattanasio
germanattanasio / app.js
Created August 1, 2015 03:42
Using Speech to Text with and shows interim results
'use strict';
// replace username and password with speech to text credentials
// audio.wav can be found here: https://github.com/watson-developer-cloud/nodejs-wrapper/blob/master/test/resources/audio.wav?raw=true
var watson = require('watson-developer-cloud'),
fs = require('fs');
var speechToText = watson.speech_to_text({
password: '<username>',
username: '<password>',