Skip to content

Instantly share code, notes, and snippets.

View edonosotti's full-sized avatar
😼
Writing

Edoardo Nosotti edonosotti

😼
Writing
View GitHub Profile
@edonosotti
edonosotti / silly-echo-bot-python-wechat.py
Last active September 25, 2023 14:04
The purpose of this code is to show the basics of creating chatbots for for the WeChat (and Weixin) platform using the Python language. It creates a simple backend that echoes back the messages it receives from users.
# The Silly Echo Bot for WeChat - Python version
#
# The purpose of this code is to show the basics of creating chatbots for the WeChat platform.
# It creates a simple backend that echoes back the messages it receives from users.
#
# See my article on Chatbots Magazine for details:
# https://chatbotsmagazine.com/building-chatbots-for-wechat-part-1-dba8f160349
#
# Tested with:
# Python 3.5.2
@edonosotti
edonosotti / silly-echo-bot-ruby-wechat.rb
Last active December 18, 2017 13:18
The purpose of this code is to show the basics of creating chatbots for the WeChat (and Weixin) platform using the Ruby language. It creates a simple backend that echoes back the messages it receives from users.
# The Silly Echo Bot for WeChat - Ruby version
#
# The purpose of this code is to show the basics of creating chatbots for the WeChat platform.
# It creates a simple backend that echoes back the messages it receives from users.
#
# See my article on Chatbots Magazine for details:
# https://chatbotsmagazine.com/building-chatbots-for-wechat-part-1-dba8f160349
#
# Tested with:
# Ruby 2.2.3
@edonosotti
edonosotti / chatbase-howto.js
Last active April 26, 2024 10:51
How to integrate chatbase in a chatbot project.
# Integrating Chatbase in your chatbot - Node.JS version
#
# The purpose of this code is to show how to integrate the Chatbase service in any chatbot.
#
# See my article on Chatbots Magazine for details:
# https://chatbotsmagazine.com/advanced-chatbot-analytics-and-sentiment-analysis-part-1-17a8e674d7e1
#
# License: MIT (https://opensource.org/licenses/MIT) (C) Edoardo Nosotti, 2017
const chatbase = require('@google/chatbase');
@edonosotti
edonosotti / chatbase-howto.py
Last active December 15, 2020 10:22
How to integrate Chatbase in a Python project.
# Integrating Chatbase in your chatbot - Python version
#
# The purpose of this code is to show how to integrate the Chatbase service in any chatbot.
#
# See my article on Chatbots Magazine for details:
# https://chatbotsmagazine.com/advanced-chatbot-analytics-and-sentiment-analysis-part-1-17a8e674d7e1
#
# License: MIT (https://opensource.org/licenses/MIT) (C) Edoardo Nosotti, 2017
from chatbase import Message, MessageSet, MessageTypes, InvalidMessageTypeError
# Multithreading in Python using the `threading` module.
# Based on: https://www.toptal.com/python/beginners-guide-to-concurrency-and-parallelism-in-python
import logging
import time
import random
from queue import Queue
from threading import Thread
@edonosotti
edonosotti / formula.md
Created March 19, 2018 12:04
Microsoft Excel formula to convert ISO 8601 date with milliseconds resolution to time stamp

Formula

This will convert an ISO 8601 date such as: 2018-03-19T10:18:08.137747874Z

to a timestamp with milliseconds resolution: 1521454688137,00

Please note that the decimal part (,00) can be stripped away, milliseconds are the last three digits.

=(((DATEVALUE(LEFT(A1;10))+TIMEVALUE(MID(A1;12;8)))-DATE(1970;1;1))*86400000)+VALUE(MID(A1;FIND(".";A1)+1;3))
@edonosotti
edonosotti / cleanup_docker_cache_on_mac.sh
Created November 13, 2018 17:15
Cleanup Docker cache on MacOSX
#!/bin/bash
docker rm $(docker ps -a -q) && \
docker rmi $(docker images -q) && \
docker volume rm $(docker volume ls |awk '{print $2}') && \
rm -rf ~/Library/Containers/com.docker.docker/Data/*
@edonosotti
edonosotti / enable_ssh_raspberry.md
Last active January 22, 2019 17:25
Enable SSH at boot on Raspberry Pi, Raspbian

Enable SSH at boot on Raspberry Pi, Raspbian

Description

SSH is not enabled by default on Raspbian at the time of writing.

Tested on:

  • Version:November 2018
  • Release date: 2018-11-13
@edonosotti
edonosotti / terraform_aws_api_gateway_account_cloudwatch.tf
Created May 10, 2019 17:16
Terraform plan to grant API Gateway permissions to write logs to CloudWatch in AWS
# NOT MY CODE! TAKEN FROM THE OFFICIAL DOCS:
# https://www.terraform.io/docs/providers/aws/r/api_gateway_account.html
# and saved here as a backup.
resource "aws_api_gateway_account" "demo" {
cloudwatch_role_arn = "${aws_iam_role.cloudwatch.arn}"
}
resource "aws_iam_role" "cloudwatch" {
name = "api_gateway_cloudwatch_global"
@edonosotti
edonosotti / simulate_load_linux.sh
Created May 25, 2019 13:06
Simulate CPU load on a linux box
#!/bin/bash
dd if=/dev/urandom | gzip -9 >> /dev/null &