Skip to content

Instantly share code, notes, and snippets.

@marcinhlybin
marcinhlybin / Usage
Last active May 30, 2023 16:08
Alive - crontab service health checker
Usage: alive [ -v|--verbose ] [ --tcp host:port ] [ --sock file_name ] [ --ps process_name | --ps fname,cmndline ]
OPTIONS
--tcp host:port check TCP connection
--sock file_name check UNIX socket
--ps process_name check process
--ps fname,cmndline check process (detailed)
--verbose|-v show status on stdout
Options could be specified multiple times.
@marcinhlybin
marcinhlybin / test.txt
Created June 6, 2019 06:31
Grep multiline
ERROR moja linia 1
stack 1
stack 2
stack 3
ERROR moja linia 2
OK moja linia
ERROR moja linia 3
stack 1
stack 2
stack 3
@marcinhlybin
marcinhlybin / 01-self-signed.txt
Last active October 7, 2023 13:35
Strongswan with Letsencrypt certificates issue
# Self-signed server certificates
Strongswan 5.6.2
Mac OS X 10.14.2 / Windows 7 / Windows 10
Without doing anything MacOS X VPN error: User Authentication failed.
After adding ca.crt and setting IP Security (IPSec) to "Always Trust", VPN connection works.
After adding ca.crt also works for Windows 7 and Windows 10.
# CA
@marcinhlybin
marcinhlybin / growth.py
Created January 30, 2019 09:39
Check dir size growth in time
#!/usr/bin/env python
import yaml
import os
import sys
from shell import shell
path = '/Users/ahes/Workspace'
growth_threshold_percent = 1
@marcinhlybin
marcinhlybin / playbook.yml
Last active May 25, 2018 18:18
Ansible BUG: include_tasks with loop and when condition
- hosts: localhost
gather_facts: false
vars:
# default_state: absent
tasks:
- name: task1
- name: task2
tasks:
- debug:
@marcinhlybin
marcinhlybin / pendulum.py
Created February 20, 2018 14:39
Pendulum DST issue
import pendulum
tz = pendulum.timezone('America/Los_Angeles')
start_time = pendulum.parse('2018-03-11 09:00:00+00:00')
end_time = pendulum.parse('2018-03-11 10:00:00+00:00')
print((end_time - start_time).in_hours()) # 1
print((end_time.in_tz(tz) - start_time).in_hours()) # 1
print((end_time - start_time.in_tz(tz)).in_hours()) # 1
print((end_time.in_tz(tz) - start_time.in_tz(tz)).in_hours()) # 1
while read line; do
if [[ $line =~ ^"["(.+)"]"$ ]]; then
arrname=${BASH_REMATCH[1]}
declare -A $arrname
elif [[ $line =~ ^([_[:alpha:]][_[:alnum:]]*)"="(.*) ]]; then
declare ${arrname}[${BASH_REMATCH[1]}]="${BASH_REMATCH[2]}"
fi
done < /etc/pushover.conf
@marcinhlybin
marcinhlybin / retry-simple.py
Created November 25, 2017 10:08
Retry HTTP connections on 5xx, simple wrapper
#!/usr/bin/env python
import requests
import time
counter = 0
max_retries = 10
def retry(func, *args, **kwargs):
for retry in range(1, max_retries+1):

Keybase proof

I hereby claim:

  • I am ahes on github.
  • I am ahes (https://keybase.io/ahes) on keybase.
  • I have a public key whose fingerprint is F845 DC2C 8530 90E2 AAA3 0187 00CD 593B B656 C6E2

To claim this, I am signing this object: