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 / snippet.html
Created November 17, 2023 16:54
Check if user agent is a bot
<script>
const checkIfUserAgentIsBot = (userAgent) => {
const robots = new RegExp(([
/bot/,/spider/,/crawl/, // GENERAL TERMS
/APIs-Google/,/AdsBot/,/Googlebot/, // GOOGLE ROBOTS
/mediapartners/,/Google Favicon/,
/FeedFetcher/,/Google-Read-Aloud/,
/DuplexWeb-Google/,/googleweblight/,
/bing/,/yandex/,/baidu/,/duckduck/,/yahoo/, // OTHER ENGINES
/ecosia/,/ia_archiver/,
@germanattanasio
germanattanasio / blockchain.py
Created December 15, 2020 21:18
Mining the nonce for a take home exam at NYU Stern
import hashlib
import time
import re
from datetime import date
# Block information
block = 1
data = 'German gets a PD'
prevHash = '0000000000000000000000000000000000000000000000000000000000000000'
@germanattanasio
germanattanasio / README.md
Last active November 27, 2019 16:45
Create a Watson Assistant service instance programmatically

Creating a service instance programmatically.

1. Create a platform apikey

In order to create/delete service instances programmatically a platform apikey needs to be used.

@germanattanasio
germanattanasio / visual-recognition-fetch.js
Last active March 27, 2018 16:30
Call classify for Visual Recognition v3 using the fetch API
// When testing in node you will have to install `form-data` and `node-fetch`. You don't need them in React Native.
// const fetch = require('node-fetch');
// const FormData = require('form-data');
const VISUAL_RECOGNITION_API = 'https://gateway-a.watsonplatform.net/visual-recognition/api';
const CLASSIFY_ENDPOINT = '/v3/classify';
const apiKey = 'API_KEY_HERE'; // replace with a valid API Key
/**
* Classifies an image using the Visual Recognition service
@germanattanasio
germanattanasio / main.py
Created March 3, 2018 04:46
Sends messages to conversation using a csv file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function # Python 3 support
import sys
import json
import datetime
import re
import csv
@germanattanasio
germanattanasio / manifest.yml
Created July 7, 2017 12:11
Deploy a Node.js Cloud-Foundry application to IBM Bluemix from Travis
---
applications:
- name: my-app-name
buildpack: sdk-for-nodejs
memory: 512M
timeout: 120 # The maximum amount of time in seconds that is used to start the application. The default value is 60 seconds.
instances: 1
command: npm start
path: .
@germanattanasio
germanattanasio / Example.java
Last active March 31, 2017 03:41
IBM JDK and SSL context
// Copy this class in the java-sdk/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/ folder
package com.ibm.watson.developer_cloud.text_to_speech.v1;
import java.util.List;
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice;
public class Example {
public static void main(String[] args) {
@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 / 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'
});
/**

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.