Skip to content

Instantly share code, notes, and snippets.

View ohlcbtc.sh
# pip install ohlc; apt install jq
# https://github.com/ubunatic/ohlc
ohlcbtc () {
while true;
do
ohlc --pab --ha -n <( curl 'https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1h' 2>/dev/null | jq -r '.[][1:5]|join(" ")' )
sleep 600
done
}
View pool_length.py
from web3 import Web3
# https://web3py.readthedocs.io/en/stable/quickstart.html
# https://docs.matic.network/docs/develop/network-details/network/
w3 = Web3(Web3.HTTPProvider("https://rpc-mainnet.matic.network"))
print(w3.isConnected())
print(w3.eth.block_number)
@juanpabloaj
juanpabloaj / logs_with_color.exs
Created Jun 25, 2021
elixir, colorful log lines
View logs_with_color.exs
require Logger
Logger.configure_backend(:console, format: "$time $metadata[$level] $levelpad$message\n")
# more colores in
# https://hexdocs.pm/elixir/1.12/IO.ANSI.html
Logger.info("colorful log line", ansi_color: :black)
Logger.info("colorful log line", ansi_color: :blue)
Logger.info("colorful log line", ansi_color: :cyan)
View docker_clean_old.service
# /etc/systemd/system/docker_clean_old.service
[Unit]
Description=delete old containers
[Service]
CPUQuota=20%
TimeoutSec=3600
ExecStart=/bin/bash /root/opt/bin/docker_clean_old
@juanpabloaj
juanpabloaj / boxplot_duration_per_project.py
Last active Jan 28, 2021
gitlab_runner_jobs_duration
View boxplot_duration_per_project.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib
sns.set(rc={'figure.figsize':(14,12)})
file_name = "duration_per_project.csv"
df = pd.read_csv(file_name, ';')
View batetry_level.ino
#include <M5StickCPlus.h>
// the setup routine runs once when M5StickC starts up
void setup() {
// initialize the M5StickC object
M5.begin();
// Lcd display
M5.Lcd.fillScreen(WHITE);
@juanpabloaj
juanpabloaj / main.go
Created Dec 22, 2020
JWT go example signing methods
View main.go
import (
"fmt"
"io/ioutil"
"time"
"github.com/dgrijalva/jwt-go"
)
func signingWithHMAC() {
@juanpabloaj
juanpabloaj / .gitignore
Last active Oct 23, 2020
go http service with concurrency
@juanpabloaj
juanpabloaj / Dockerfile
Last active Jun 4, 2020
phoenix gitlab monitor and haproxy
View Dockerfile
FROM haproxy:1.7
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
@juanpabloaj
juanpabloaj / Dockerfile
Created May 4, 2020
haproxy strip path prefix
View Dockerfile
FROM haproxy:1.7
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg