Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
ZiTAL / example.sh
Created November 25, 2022 11:48
mail: fish vs bash
# bash style:
/usr/bin/mail -s "Title" -r sender@sender.com receptor@receptor.com <<< "BODY"
# fish and bash:
echo "Body" | /usr/bin/mail -s "Title" -r sender@sender.com receptor@receptor.com
@ZiTAL
ZiTAL / regex.sh
Created November 22, 2022 11:47
bash: "group" using grep with regex
#!/bin/bash
INPUT="harry_potter_2001_720p_philosphers_stone.mkv"
#INPUT="S01E05_fringe_1080p.mkv"
determinedQuality=$(echo "$INPUT" | grep -Po '[0-9]{3,4}[PpIi]')
determinedYear=$(echo "$INPUT" | grep -Po '[0-9]{4}[^A-Za-z]' | grep -Po '[0-9]{4}')
determinedEpisode=$(echo "$INPUT" | grep -Po '[Ss]{1}[0-9]{2}[Ee][0-9]{2}|[0-9]x[0-9]{2}')
echo "quality: $determinedQuality"
@ZiTAL
ZiTAL / 000-default.conf
Last active November 9, 2022 20:52
apache: amule + transmission configuration
<VirtualHost *:80>
# ...
RewriteRule "^/amule$" "/amule/" [L,R=301]
RewriteRule "^/transmission$" "/transmission/web/" [L,R=301]
RewriteRule "^/transmission/$" "/transmission/web/" [L,R=301]
# ...
ProxyPass /amule http://amule.pi4:4711
ProxyPassReverse /amule http://amule.pi4:4711
ProxyPass /transmission http://transmission.pi4:9091/transmission
@ZiTAL
ZiTAL / transfer.sh
Last active November 8, 2022 11:15
bash: transfer.sh
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2
exit 1
fi
if tty -s; then
file="$1"
file_name=$(basename "$file")
if [ ! -e "$file" ]; then
echo "$file: No such file or directory">&2
@ZiTAL
ZiTAL / credentials.json
Last active October 20, 2022 06:59
Instagram Bot:
{
"user": "user",
"passwd": "passwd"
}
@ZiTAL
ZiTAL / selenium_firefox.py
Created October 14, 2022 09:15
selenium python: Firefox headless
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# selenium drivers: https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/
# pip3 install selenium webdriver-manager
# for custom firefox installation: link firefox to /usr/bin/firefox, example: ln -s /opt/firefox/firefox-bin /usr/bin/firefox
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.options import Options
@ZiTAL
ZiTAL / .bashrc
Last active August 3, 2022 08:22
debian git-prompt
# ~/.bashrc
#...
source ~/.git-prompt.sh
#PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$$(__git_ps1 " (%s)") '
#PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 ":git-branch:%s")$ '
#PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]:\[\033[01;33m\]$(__git_ps1 "git-branch:%s")\[\033[00m\]$ '
#PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]:\[\033[01;33m\]$(__git_ps1 "git[%s]")\[\033[00m\]$ '
PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(__git_ps1 "\[\033[00m\]:\[\033[01;33m\]git[%s]")\[\033[00m\]$ '
@ZiTAL
ZiTAL / example.js
Created June 17, 2022 12:58
js: how to know what type of object is for typescript
/*
When we program in typescript, sometimes we don't know what type of object is, and the declaration of the variable is erroneous with type "object"
variable.toString()
*/
console.log(document.querySelector('body').toString())
/*
output:
"[object HTMLBodyElement]"
*/
@ZiTAL
ZiTAL / a.sh
Last active January 28, 2022 07:54
fluxbox: vscode enable github sync, enable copilot etc...
#!/bin/bash
su
apt-get install gdm3
exit
@ZiTAL
ZiTAL / index.php
Created January 21, 2022 14:55
nginx: apache PATH_INFO equivalent
<?php
if(!isset($_SERVER['PATH_INFO']))
$_SERVER['PATH_INFO'] = preg_replace("/\?".preg_quote($_SERVER['QUERY_STRING'])."/", '', $_SERVER['REQUEST_URI']);