Skip to content

Instantly share code, notes, and snippets.

# grabbed from S.O. and then tuned it (sort of)
# SSH agent
ssh_pid_file="$HOME/.config/ssh-agent.pid"
SSH_AUTH_SOCK="$HOME/.config/ssh-agent.sock"
if [ -z "$SSH_AGENT_PID" ]
then
# no PID exported, try to get it from pidfile
SSH_AGENT_PID=$(cat "$ssh_pid_file")
fi
@carlok
carlok / frame_extractor.bash
Last active August 8, 2022 15:39
Bash to extract frames from a list of MP4 using FFMPEG
# choose one or the other
# 1
# oneliner: all JPGs in a single folder (don't use it when you are going to have thousands of images)
for i in $(ls 2022_07_*.MP4 | awk -F "." '{print $1}'); do ffmpeg -i $i.MP4 -qscale:v 1 -s 1920x1080 $(printf '%s' $i)_%8d.jpg; done
# 2
# each mp4 generates its own jpg folder
for i in $(ls 2022_07_13_*.MP4 | awk -F "." '{print $1}')
do
@carlok
carlok / 0_export_public_key.py
Last active May 13, 2023 21:51 — forked from aellerton/0_export_public_key.py
Python sign message with private key and verify with public key
#!/usr/bin/env python
"""Extract the public key from the private key and write to a file.
"""
from Crypto.Hash import SHA256
from Crypto.Signature import PKCS1_v1_5
from Crypto.PublicKey import RSA
with open("private_key.pem", "r") as src:
private_key = RSA.importKey(src.read())
@carlok
carlok / binance_repay_margin_loan.py
Created September 27, 2021 07:31
Binance repay margin loan
from binance.client import Client
api_key = 'your_api_key'
api_secret = 'your_api_secret'
asset = 'USDT'
amount = '1000' # example value as string
client = Client(api_key, api_secret)
transaction = client.repay_margin_loan(asset=asset, amount=amount)
@carlok
carlok / Flowers.md
Last active June 17, 2021 12:35
A few Italian flowers names
  • ABELIA
  • ACHILLEA
  • ACIDANTHERA
  • ACONITO
  • ADONIDE SCARLATTO
  • AGAPANTO
  • AGLIO SELVATICO
  • AGRIMONIA COMUNE
  • ALISSO
  • ALLIARIA
@carlok
carlok / bunny_pop.rb
Created October 10, 2020 10:07
Ruby Bunny AMQP RabbitMQ pop basic local worker example
require "bunny"
# vhost create
# curl -u guest:guest -X PUT http://localhost:15672/api/vhosts/ckvh1
#
# push message in a vhost queue
# curl -i -u guest:guest -H "content-type:application/json" -X POST \
# http://localhost:15672/api/exchanges/ckvh1/amq.default/publish \
# -d '{"properties": {}, "routing_key": "aaa", "payload": "bbb", "payload_encoding": "string"}'
@carlok
carlok / foit-2020-06.md
Last active June 17, 2020 18:37
FOIT - 2020-06 Corso Software Libero e Cloud
@carlok
carlok / influx_client_basic.py
Last active August 5, 2022 21:10
How to send cpu, disk and memory percentage to InfluxDB (InfluxData) with callbacks (using psutil for operating system data)
"""
A python example regarding how to send CPU, disk and memory usage percentages to InfluxDB, using callbacks and psutil
(using psutil for operating system data)
There is also a basic query to plot the data on an Influx dashboard.
pip3 install influxdb-client psutil
On Influx, then you can query "memory", for example, with
@carlok
carlok / bitbucket-pipelines.yml
Last active May 25, 2020 12:17
How to force BitBucket to push a Docker image to AWS ECR after a git tag
image: python:3.7.3
options:
docker: true
pipelines:
tags:
'v*': # the tag is "vSomething" like "v0.4.3"
- step:
name: Build docker image and push to AWS ECR
@carlok
carlok / bitbucket-pipelines.yml
Created March 28, 2020 17:14
How to force BitBucket to push a Docker image to AWS ECR after a git tag
#image: atlassian/default-image:2
image: python:3.7.3
pipelines:
tags:
'v*': # the tag is "vSomthing" like "v-0.4.2"
- step:
name: Build docker image and push to AWS ECR
services:
- docker