Skip to content

Instantly share code, notes, and snippets.

View haron's full-sized avatar

Alexander Ryabov haron

View GitHub Profile
@haron
haron / README.md
Last active February 6, 2025 19:54
Bash script to install Tailscale in unsupported countries (in case if you get HTTP 451 while trying to download package)

This is a bash script to install and upgrade Tailscale in unsupported countries — in case if you get HTTP 451 while trying to download package. Works at least on Ubuntu 22.04 (but probably with Debian and other Ubuntu versions as well).

Usage:

git clone https://gist.github.com/8b2a6244e124766ee0d6396389ac7f34.git tailscale-install-451 && cd tailscale-install-451
./tailscale-install-451.sh host1 host2 ...
@haron
haron / tmstatus.py
Last active September 30, 2023 20:11
Command line tool to show Time Machine backup progress in a human-readable form (Python 3.8+)
#!/usr/bin/env python
import plistlib
import subprocess
res = subprocess.run("tmutil status -X", shell=True, capture_output=True).stdout
data = plistlib.loads(res)
if running := data["Running"]:
print("Backup is running")
print("Progress: %s%%" % (round(data.get("Progress", {}).get("Percent", -1) * 100, 2)))
print("BackupPhase:", data["BackupPhase"])
@haron
haron / Бекап.md
Last active May 27, 2021 13:59
Бекап личных данных

Общие соображения: есть несколько причин, по которым сложно делать бекапы личных данных. Кажется, что бекапы это а) непонятно (надо разбираться с софтом), б) всё или ничего (глупо бекапить что-то одно, когда остальное не бекапится), в) дорого (надо покупать диски или платить за сервисы) и г) напряжно (про них надо помнить). Из-за этого думать о бекапах неприятно, и заниматься ими обычно не хочется.

Развенчание мифов: а) в маке и windows есть встроенный бекап, который достаточно хорош; б) лучше бекапить хоть что-то, чем вообще ничего - лично я рекомендую начать с фотоархива; в) внешний диск стоит 50-100 баксов и проживет пару лет, годовая подписка на Backblaze стоит $60 - не копейки, но эти расходы часто оправданы; г) на маке Time

@haron
haron / Makefile
Last active April 23, 2018 13:15
Скрипт для установки SOCKS-прокси
HOST = [email protected]
PORT = 9905
REMOTE_PATH ?= danted
CONTAINER ?= danted_dante_1
.NOTPARALLEL: all
.EXPORT_ALL_VARIABLES: all
all: stop install-docker build users status links
"""
feeds.py - minimalistic console RSS reader
Installation: pip install -U feedparser
Usage:
python3 feeds.py https://hnrss.org/frontpage https://www.reddit.com/r/Python/new.rss?limit=10
or, to get 10 entries from all feeds, shuffled:
SAMPLE=10 python3 feeds.py https://hnrss.org/frontpage https://www.reddit.com/r/Python/new.rss?limit=10
"""
import os, sys, feedparser, functools, operator, time, random

How to get (almost) free monitoring calls via UptimeRobot and Nexmo

IMPORTANT: Nexmo calls are not free. You should pay on per-call basis according to their voice pricing. This shouldn't be a huge concern unless your website goes down twice a day.

  1. Create accounts at https://uptimerobot.com/ and https://nexmo.com/ (you'll get €2 welcome credit from Nexmo).
  2. Add your phone number to Nexmo, then get your API key and secret at settings.
  3. Go to UptimeRobot settings.
  4. Press "Add Alert Contact" and choose "Web-Hook".
@haron
haron / rake.sh
Last active August 29, 2015 14:23 — forked from turadg/rake.sh
Rake bash completion, faster
# vim: ft=sh
#
# bash completion for rake
#
# some code from on Jonathan Palardy's http://technotales.wordpress.com/2009/09/18/rake-completion-cache/
# and http://pastie.org/217324 found http://ragonrails.com/post/38905212/rake-bash-completion-ftw
#
# For details and discussion
# http://turadg.aleahmad.net/2011/02/bash-completion-for-rake-tasks/
#
@haron
haron / r.html
Created December 17, 2013 07:18
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Referer remover</title>
<script>
window.location.href = window.location.search.slice(1);
</script>
</head>
<body>
@haron
haron / .pomodoro.sh
Created October 4, 2013 17:16
Pomodoro timer function for your .bashrc
_settitle () {
echo -ne "\033]0;$@\007" 1>&2
}
pomodoro() {
T=15
_settitle "Pomodoro $T min"
S=$((60*T))
echo
(for I in `seq $S`; do echo -n " "; sleep 1; done) | pv -i 1 -s $S -w 100 -N "pomodoro $T min" -c -F "%N %t %p %e"
echo
pyasn1==0.1.6