Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
ZiTAL / temp.sh
Last active June 26, 2024 07:58
gnu/linux bash: temp of cpu/gpu/hdd
#!/bin/bash
CPU_NAME=`awk -F: '/model name/ { gsub(/^ */, "", $2); print $2 }' /proc/cpuinfo | head -1`
CPU_01=`sensors | grep -E "Tctl:\s+\+[0-9]+\.[0-9]+" | awk '{print $2}' | grep -oP '[0-9]+\.[0-9]+'`
CPU_02=`sensors | grep -E "Tccd1:\s+\+[0-9]+\.[0-9]+" | awk '{print $2}' | grep -oP '[0-9]+\.[0-9]+'`
GPU_NAME=`/usr/bin/nvidia-smi | grep -E 'NVIDIA\s' | awk '{print $3, $4, $5, $6}'`
GPU_01=`/usr/bin/nvidia-smi | grep -E '[0-9]+C' | awk '{print $3}' | grep -oP '[0-9]+'`
HDD01_00=`lsblk -d -o NAME,MODEL | tail -n 2 | head -n 1 | awk '{print $2,$3}'`
HDD01_01=`sensors | head -n 10 | tail -n 1 | grep -oP '\+[0-9]+\.[0-9]+' | head -n 1 | grep -oP '[0-9]+\.[0-9]+'`
@ZiTAL
ZiTAL / zeep.sh
Created June 19, 2024 14:15
python3: zeep offline instalatu
# instalatu
pip3 install
# requirements sortu
pip3 freeze > requirements.txt
# fitxategiak mugitu
# zerbitzari berrian instalatu
pip install -r ./requirements.txt --no-index --find-links ./
@ZiTAL
ZiTAL / ia.php
Last active June 17, 2024 15:43
php / python: automatize upscaling videos using ffmpeg and realesrgan
<?php
new ia(
[
'extensions' => ['mp4'],
'suffix' => '-ia',
'from' => '/home/zital/Videos/to_encode/',
'to' => '/home/zital/Videos/encoded/',
'ffmpeg_bin' => '/usr/bin/ffmpeg',
'ffmpeg_argv' => '-b:v 4340k -an -c:v h264_nvenc -pix_fmt yuv420p',
@ZiTAL
ZiTAL / client.php
Last active June 20, 2024 13:28
SOAP: php simple example
<?php
// Disable WSDL caching
ini_set("soap.wsdl_cache_enabled", "0");
$wsdl = "http://localhost:8000/service.wsdl";
try
{
$a = 4;
$b = 5;
@ZiTAL
ZiTAL / .env
Last active May 15, 2024 07:07
php / laravel: ldap samaccountname
LDAP_DOMAIN="zital.lan"
LDAP_BASEDN="dc=zital,dc=lan"
LDAP_GROUPS='["Group01", "Group02"]'
LDAP_ATTRS='["*"]'
LDAP_HOSTS='["ldap01.zital.lan:389","ldap02.zital.lan:389","ldap02.zital.lan:389"]'
@ZiTAL
ZiTAL / ldap.sh
Created May 15, 2024 06:53
linux: ldap microsoft samaccountname example
#!/bin/bash
HOST="ldap.zital.eus"
BASEDN="dc=zital,dc=lan"
USER="zital@zital.eus"
PASSWD="12345"
ldapsearch -x -H ldap://${HOST} -b ${BASEDN} -D ${USER} -w ${PASSWD} "(samaccountname=${USER})"
@ZiTAL
ZiTAL / modules-rtmp.conf
Created May 11, 2024 18:58
nginx rtmp + ffmpeg
# /etc/nginx/modules-available/rtmp.conf
rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish 127.0.0.1;
deny publish all;
application live {
@ZiTAL
ZiTAL / porru.js
Last active May 3, 2024 07:14
openttd: automatic translate
/*
install:
npm install prompt-sync --save-dev
npm install testcafe --save-dev
create:
env.json with github credentials: {user: user, passwd: passwd}
exec:
npx testcafe firefox:headless porru.js
@ZiTAL
ZiTAL / config.fish
Created April 22, 2024 08:25
fish: use full path in terminal
# .config/fish/config.fish
if status is-interactive
# Commands to run in interactive sessions can go here
set -g fish_prompt_pwd_dir_length 0
end
@ZiTAL
ZiTAL / 001.sh
Last active May 22, 2024 17:23
ffmpeg examples
#/bin/bash
# resize and crop
# ffmpeg: 1440x1072 -> 1452x1080 -> 1440x1080 rockchip h264_rkmpp
ffmpeg-rockchip -i input.mp4 -b:v 2472k -vcodec h264_rkmpp -s 1452x1080 -r 30 -g 60 -b:a 160k -ar 44100 -threads 4 tmp.mp4
ffmpeg-rockchip -i tmp.mp4 -b:v 2472k -vcodec h264_rkmpp -s 1440x1080 -r 30 -g 60 -filter:v \"crop=1440:1080:6:0\" -aspect 4:3 -acodec copy -threads 4 output.mp4