Skip to content

Instantly share code, notes, and snippets.

Connect to WiFi network
WIFI:T:WPA2;S:MyNetworkName;P:ThisIsMyPassword;H:true;
T:WPA2 - Authentication type; can be WEP or WPA, or leave empty for no password.
S:MyNetworkName - Network SSID. Required.
P:ThisIsMyPassword - Password, ignored if T is left blank.
H:true - Optional. True if the network SSID is hidden.
Как быстро и безопасно управлять переменными окружения на macOS с помощью keychain.
По сути там уже все есть, нужно только добавить обертку.
Делаем раз:
tee ~/keychain-env.sh <<'EOF'
function keychain-env-read () {
security find-generic-password -w -a ${USER} -D "environment variable" -s "${1}"
}
function keychain-env-add () {
[ -n "$1" ] || print "Missing environment variable name"
@pessom
pessom / nginx.conf
Last active August 3, 2022 21:21 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs https://ssl-config.mozilla.org/
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@pessom
pessom / sshpass build.sh
Last active March 6, 2019 14:52
Install sshpass on os x
curl -O -L https://kent.dl.sourceforge.net/project/sshpass/sshpass/1.06/sshpass-1.06.tar.gz
tar xvzf sshpass-1.06.tar.gz
cd sshpass-1.06/
./configure
make
sudo make install
@pessom
pessom / quick_punycode_encode_decode_example.py
Created March 2, 2018 15:43 — forked from floer32/quick_punycode_encode_decode_example.py
quick example of encoding and decoding a international domain name in Python (from Unicode to Punycode or IDNA codecs and back). Pay attention to the Unicode versus byte strings
# INCORRECT! DON'T DO THIS!
>>> x = "www.Alliancefrançaise.nu" # This is the problematic line. Forgot to make this a Unicode string.
>>> print x
www.Alliancefrançaise.nu
>>> x.encode('punycode')
'www.Alliancefranaise.nu-h1a31e'
>>> x.encode('punycode').decode('punycode')
u'www.Alliancefran\xc3\xa7aise.nu'
>>> print x.encode('punycode').decode('punycode')
www.Alliancefrançaise.nu
@pessom
pessom / check_hash.py
Created February 24, 2018 12:29 — forked from xen/check_hash.py
telegram site auth
# implementation of Telegram site authorization checking algorithm
# for more information https://core.telegram.org/widgets/login#checking-authorization
import collections
import hmac
import hashlib
def check_string(d, token):
secret = hashlib.sha256()
secret.update(token.encode('utf-8'))
@pessom
pessom / example.conf
Created February 13, 2018 09:59
Haproxy to Sentinel powered Redis example conf
global
log /dev/log local0 notice
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
listen mysql-corp 0.0.0.0:3306
@pessom
pessom / IPtoHEX
Created February 10, 2018 16:39
Преобразование ip/network в hex
def ip2hex(cidr, router):
addr, mask = cidr.split("/")
mask = int(mask)
addr = [("%2s" % hex(int(i))[2:]).replace(" ", "0") for i in addr.split(".") if i != "0"]
parts = mask / 8 - len(addr)
if mask % 8 > 0:
parts += 1
if parts > 0:
for i in range(int(parts)):
addr.append("00")
@pessom
pessom / gist:babaad22107a96cae9271cbc0bca983f
Created December 3, 2017 17:52 — forked from declaresub/gist:2cf0e6f4a08129e2a4e4
Python logging.config.dictConfig example
#! /usr/bin/python
from logging import getLogger
from logging.config import dictConfig
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters':
pessom@web:/etc/systemd/system$ cat send_top.service
#Ansible managed
[Unit]
Description=Run send_top scripts initialise timer
After=network.target
[Service]
User=root
Group=root