Skip to content

Instantly share code, notes, and snippets.

View pjcalvo's full-sized avatar

Pablo Calvo pjcalvo

View GitHub Profile
@pjcalvo
pjcalvo / code.py
Last active July 17, 2023 13:01
sensor + requests
from machine import Pin, ADC
import machine
import network
import time
from api import send_humidity_values
######### constants
READ_DELAY = 60 # delay between readings every minute
WIFI_DELAY = 0.5 # delay between readings every minute
@pjcalvo
pjcalvo / main.go
Created July 13, 2023 08:47
Trie implementation go
package main
import (
"fmt"
"strings"
)
type Node struct {
Children map[string]*Node
}
package main
import (
"regexp"
"strings"
"testing"
)
const (
expected = "this-is-an-experiment"
@pjcalvo
pjcalvo / gmail.js
Last active July 28, 2021 21:22
Get user_id with google oauth using google sdk
// npm i -D googleapis
// npm i -D js-base64
/*
Create a oauth2 credential on https://console.developers.google.com/apis/credentials (or ask ur developers to create one)
Download the corresponding credentials.json file
The first time this file run it generates a token.json which contains the user information (sensitive).
*/
// node gmail.js
@pjcalvo
pjcalvo / influxdb-listener-for-locustio
Last active November 23, 2020 13:39
Custom InfluxDB listener for locustIO Events
import logging
import sys
import atexit
import traceback
from datetime import datetime
from locust.exception import InterruptTaskSet
import gevent
const { remote } = require('webdriverio');
(async () => {
const browser = await remote({
logLevel: 'trace', capabilities: { browserName: 'chrome'}
})
await browser.url('http://zzzscore.com/1to50/en/?ts=1592666149743') // navigate
result = await browser.execute(function(){
for(i=1;i<26;i++){
@pjcalvo
pjcalvo / single-page-scrapper.py
Created May 26, 2020 17:12
A script to crawl a single page using scrapy and report it to a csv file.
"""
A script to crawl a single page using scrapy and report it to a csv file.
1) Install a virtual env
```bash
python3 -m venv venv
. venv/bin/activate
pip install scrapy
```
2) Run the command with
@pjcalvo
pjcalvo / docker-compose.yml
Last active August 3, 2021 00:17
InfluxDB + Grafana
# InfluxDB + Grafana compose file.
# With data persistency
version: '3'
services:
influxdb:
image: influxdb:1.7
container_name: influxdb
ports:
- "8086:8086"