Skip to content

Instantly share code, notes, and snippets.

@jonasjancarik
jonasjancarik / run_script_over_ssh.sh
Created June 29, 2023 13:24
Run scripts on one more hosts using SSH
#!/bin/bash
set -e
# Ensure we have at least two arguments: the script file and at least one host
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <script_file> <host1> <host2> ... <hostN>"
exit 1
fi
# Get script file and hosts from arguments
@jonasjancarik
jonasjancarik / parse-task.sh
Created March 1, 2023 14:31
Elasticsearch tasks API response parser
#!/bin/bash
# Read the input from the curl command
input=$(cat -)
# Extract the running_time_in_nanos field from the input
running_time_in_nanos=$(echo $input | jq '.task.running_time_in_nanos')
# Extract the values of "total" and the sum of "updated", "created", "deleted", and "noops" from the input
total=$(echo $input | jq '.task.status.total')
@jonasjancarik
jonasjancarik / install_protonvpn.sh
Last active April 5, 2023 12:28
Install proton-vpn linux-cli-community (Ubuntu)
#!/bin/bash
set -e
# colors
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
ENDCOLOR="\e[0m"
@jonasjancarik
jonasjancarik / install.sh
Last active February 9, 2023 12:38
ProtonVPN from Terminal - use a random config file
echo -e "\n\nDownloading custom ProtonVPN scripts...\n\n"
curl -s -o ~/protonvpn.sh "https://gist.githubusercontent.com/jonasjancarik/d5b73a1c1274defd290304db1cb0dfaf/raw/protonvpn.sh?$RANDOM"
chmod +x ~/protonvpn.sh
curl -s -o ~/Desktop/protonvpn_script.desktop "https://gist.githubusercontent.com/jonasjancarik/d5b73a1c1274defd290304db1cb0dfaf/raw/protonvpn_script.desktop?$RANDOM"
chmod 755 ~/Desktop/protonvpn_script.desktop
gio set ~/Desktop/protonvpn_script.desktop metadata::trusted true
curl -s -o ~/Desktop/protonvpn_disconnect.desktop "https://gist.githubusercontent.com/jonasjancarik/d5b73a1c1274defd290304db1cb0dfaf/raw/protonvpn_disconnect.desktop?$RANDOM"
chmod 755 ~/Desktop/protonvpn_disconnect.desktop
gio set ~/Desktop/protonvpn_disconnect.desktop metadata::trusted true
echo -e "\n\n\e[32m$(tput bold)The script is now installed.$(tput sgr0)\e[0m \nUse the \"ProtonVPN (Free)\" shortcut on the desktop to launch it.\n\n"
@jonasjancarik
jonasjancarik / change_tor_country.desktop
Last active January 19, 2023 12:58
Bash script to set the exit node country for the Tor Browser
[Desktop Entry]
Type=Application
Name=Change Tor Country
Exec=sh -c "~/Desktop/Browser/change_tor_country.sh"
Icon=gnome-globe-net
Terminal=true
echo "Writing a script to toggle the settings (~/toggle_dns.sh)..."
if echo "#!/bin/bash
if grep -Fxq \"dns=none\" /etc/NetworkManager/NetworkManager.conf
then
echo \"[main]
plugins=ifupdown,keyfile
[ifupdown]
managed=false\" > /etc/NetworkManager/NetworkManager.conf
@jonasjancarik
jonasjancarik / stream.py
Last active March 22, 2022 14:10
Tweepy 4+ Streaming Example
import tweepy
from dotenv import load_dotenv
import os
load_dotenv()
class Listener(tweepy.Stream):
def __init__(self, *args, **kwargs):
super(Listener, self).__init__(*args)
(koronavirus OR koronaviru OR koronavirusu OR koronavire OR koronaviruse OR koronavirem OR koronavirusem OR covid OR covidu OR covide OR covidem OR covid-19 OR covidový OR covidového OR covidovému OR covidovém OR covidovým OR covidová OR covidové OR covidovou OR covidoví OR covidových OR covidovými OR koronavirový OR koronavirového OR koronavirovému OR koronavirovém OR koronavirovým OR koronavirová OR koronavirové OR koronavirovou OR koronaviroví OR koronavirových OR koronavirovými)
AND
(vakcína OR vakcíny OR vakcíně OR vakcínu OR vakcíno OR vakcínou OR vakcín OR vakcínám OR vakcínách OR vakcínami OR očkování OR očkováním OR očkováních OR očkováními OR očkovací)
@jonasjancarik
jonasjancarik / dvtv-playback-speed-userscript.js
Last active December 16, 2019 15:18
DVTV Playback Speed Controls (userscript)
// ==UserScript==
// @name DVTV Playback Speed Controls
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Adds playback speed controls to the DVTV video player
// @author You
// @match https://video.aktualne.cz/dvtv/*
// @grant none
// ==/UserScript==
@jonasjancarik
jonasjancarik / one-liners.md
Last active January 10, 2020 07:02
Bash/cmd/PS one-liners and other helpful stuff

Add BOM to CSV files (to open UTF-8 CSVs correctly in Excel):

sed -i '1s/^\(\xef\xbb\xbf\)\?/\xef\xbb\xbf/' *.csv

To check if a file contains UTF-8 BOM at header:

# hexdump -n 3 -C 2.txt
00000000 ef bb bf