Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
juanpabloaj / hoursSameName.js
Last active March 19, 2022 06:14
AppsScript: total hours of events with same name.
// add menu
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [{name:"Calcular Horas", functionName: "calculateHours"}];
ss.addMenu("Hours", menuEntries);
// calcular al iniciar
calculateHours();
}
function count_hours(cal_id, event_name){
@juanpabloaj
juanpabloaj / neovim.spec
Last active January 2, 2022 14:18
neovim centos 6 spec
# yum install -y rpm-build rpmdevtools yum-utils centos-release-scl-rh
# rpmdev-setuptree
# mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp}
# spectool -g -R rpmbuild/SPECS/neovim.spec
# yum-builddep -y rpmbuild/SPECS/neovim.spec
# source scl_source enable devtoolset-6
# rpmbuild -ba rpmbuild/SPECS/neovim.spec
%define build_timestamp %(date +"%Y%m%d%H%M")
@juanpabloaj
juanpabloaj / neovim-centos-6.sh
Last active January 2, 2022 14:18
Install Neovim on Centos 6 from source
# install gcc 6.x
# Install CentOS SCLo RH repository:
yum install centos-release-scl-rh
# Install devtoolset-6-gcc rpm package:
yum install devtoolset-6-gcc
# activate scl
scl enable devtoolset-6 bash
# Prerequisites
sudo yum -y install libtool autoconf automake cmake gcc gcc-c++ make pkgconfig unzip patch gettext
@juanpabloaj
juanpabloaj / ohlcbtc.sh
Last active December 9, 2021 12:19
OHLC BTC
# pip install ohlc; apt install jq
# with other token, ohlcbtc ETHUSDT
ohlcbtc () {
token=${1:-BTCUSDT}
while true;
do
ohlc --pab --ha -n <( curl "https://api.binance.com/api/v3/klines?symbol=${token}&interval=1h" 2>/dev/null | jq -r '.[][1:5]|join(" ")' )
sleep 3600
done
@juanpabloaj
juanpabloaj / pool_length.py
Created July 9, 2021 22:35
get pool length
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 / docker_clean_old.service
Created June 1, 2021 23:20
delete old containers
# /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 / Makefile
Last active April 17, 2021 03:56
Cplex OSX build example
# reference
# $HOME/Applications/IBM/ILOG/CPLEX_Studio1262/cplex/examples/x86-64_osx/static_pic/Makefile
SYSTEM = x86-64_osx
LIBFORMAT = static_pic
CPLEXDIR = /Users/$(shell whoami)/Applications/IBM/ILOG/CPLEX_Studio1262
CONCERTDIR = $(CPLEXDIR)/concert
CPLEXLIBDIR = $(CPLEXDIR)/cplex/lib/$(SYSTEM)/$(LIBFORMAT)
@juanpabloaj
juanpabloaj / boxplot_duration_per_project.py
Last active January 28, 2021 13:29
gitlab_runner_jobs_duration
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, ';')
@juanpabloaj
juanpabloaj / batetry_level.ino
Created January 10, 2021 15:22
battery_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 December 22, 2020 20:35
JWT go example signing methods
import (
"fmt"
"io/ioutil"
"time"
"github.com/dgrijalva/jwt-go"
)
func signingWithHMAC() {