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 / latin-1-regexp.js
Last active November 4, 2020 13:36
Basic Latin-1 Letter Regular Expression (JavaScript)
var regexp = /^[A-z\u00C0-\u00ff\s'\.,-\/#!$%\^&\*;:{}=\-_`~()]+$/,
ascii = ' hello !@#$%^&*())_+=',
latin = 'Panamá, ratón, cortés, árbol, azúcar, ángel',
chinese = ' 你 好 ';
console.log(regexp.test(ascii)); // true
console.log(regexp.test(latin)); // true
console.log(regexp.test(chinese)); // false
@germanattanasio
germanattanasio / sh
Created July 20, 2015 21:37
Remove .DS_Store files
sudo find / -name ".DS_Store" -depth -exec rm {} \;
@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>',
@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 / stt.sh
Last active November 22, 2021 17:21
curl commands to use the Speech to Text service
#!/bin/sh
# This script clears the terminal, call the IBM Watson Speech to Text service.
USERNAME="<SERVICE_USERNAME>"
PASSWORD="<SERVICE_PASSWORD>"
SESSION_ID="<SESSION_ID>" # you will get this after running (1)
# 1. Create a session:
curl -X POST -b cookies.txt -c cookies.txt -u $USERNAME:$PASSWORD -d "{}" "https://stream.watsonplatform.net/speech-to-text/api/v1/sessions"
# This returns you a session URL. Note that the client needs to support cookies for sessions to work.
@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);
@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"),

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.