Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
ZiTAL / elhuyar.py
Last active January 11, 2024 07:55
python: elhuyar-i hitzak itzultzeko eskatzeko script-a
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
import requests
import re
from lxml import html
def printError(search):
print("Errorea gertatu da, ziur aski sartu duzun hitza ez da hiztegian agertzen")
@ZiTAL
ZiTAL / parse.py
Last active December 29, 2023 10:56
Mediawiki: How to parse all pages from the Main page and convert it to a pdf
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
import requests
import re
class api:
url = 'https://wiki.zital.eus/api.php'
# sep egindakoak ezberdintzeko erabiliko dugu, bestela bukleetan behin eta berriz sartuko da
@ZiTAL
ZiTAL / fmod.py
Last active November 9, 2023 14:34
python: change modification date to folders/files from lower to higher date alphabetically
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# usage: python3 fmod.py "/home/zital/Music"
import os, sys, datetime
def getResources(path):
resources = []
@ZiTAL
ZiTAL / fstab
Last active November 9, 2023 06:47
gnu/linux: set tmpfs size
# /etc/fstab
#...
tmpfs /tmp tmpfs defaults,rw,nodev,nofail,noatime,nosuid,size=8G 0 0
#...
@ZiTAL
ZiTAL / help.md
Created November 3, 2023 08:30
linux mint: Enable WIFI Broadcom BCM43142

BIOS

ENABLE UEFI and DISABLE Secure Boot

@ZiTAL
ZiTAL / youtube2yewtube.js
Last active October 22, 2023 07:55
violentmonkey: convert youtube links to yewtu.be
// ==UserScript==
// @name YouTube Link Replacer
// @namespace Violentmonkey Scripts
// @match https://www.youtube.com/*
// @match https://m.youtube.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function()
@ZiTAL
ZiTAL / LocalSettings.php
Last active November 8, 2023 08:51
mediawiki: nginx + pretty urls + sql backup + crontab
<?php
//...
$wgScriptPath = "";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
//...
@ZiTAL
ZiTAL / telegram.py
Created October 16, 2023 14:16
python: telegram bot: escape markdown special chars
# https://core.telegram.org/bots/api#markdownv2-style
def mdEscapeSpecialChars(msg):
special = r'_*[]()~`>#+-=|{}.!'
pattern = r'([' + re.escape(special) + '])'
replacer = lambda match: '\\' + match.group(1)
output = re.sub(pattern, replacer, msg)
return output
@ZiTAL
ZiTAL / example.sh
Created September 26, 2023 11:22
config external smtp to setup debian to send mail
echo "Testing msmtp from ${HOSTNAME} with mail command" | mail -s "hi there" zital@riseup.net
@ZiTAL
ZiTAL / index.php
Last active August 23, 2023 08:29
php: minecraft server log output
<?php
$file_name = 'latest.log';
$f_mod = date('Y-m-d H:i:s', filemtime($file_name));
$log_file = file_get_contents($file_name);
$lines = preg_split("/\n/", $log_file);
$log = '';
foreach($lines as $line)
{
// [22:41:42] [User Authenticator #7/INFO]: UUID of player arkkuso is aa1111a1-a1aa-1111-1a1a-aa11a1a111aa