Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
pessom / curl.md
Created September 26, 2017 10:01 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@pessom
pessom / haproxy.cfg
Created August 25, 2017 18:49 — forked from fumin/haproxy.cfg
Haproxy config file for SSL and basic authentication
# Haproxy config file for SSL and basic authentication
#
# Since ssl is needed, we need to use
# `make TARGET=linux26 USE_OPENSSL=1 ADDLIB=-lz` to install haproxy.
# Also, haproxy version must be haproxy-1.5-dev19 or above.
#
# An example curl command that queryies pic-collage.com/api/collages/feed is
# `curl -k -v -u 'collages:password' 'https://ec2-ip.compute-1.amazonaws.com/api/collages/feed'`
userlist collages_dyno
@pessom
pessom / haproxy.cfg
Created August 24, 2017 12:45 — forked from ryzy/haproxy.cfg
HAProxy conf with SSL termination and HTTP/2 support
global
#debug
chroot /var/lib/haproxy
user haproxy
group haproxy
pidfile /var/run/haproxy.pid
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
@pessom
pessom / repo-full-copy.sh
Last active August 8, 2017 15:07 — forked from AgiosAndreas/repo-full-copy.sh
Полный перенос git репозитория на другой сервер
# Клонируем исходный репозиторий без рабочего каталога (--bare)
git clone --bare https://github.com/exampleuser/old-repository.git
cd old-repository.git
# Делаем mirror-push(будут скопированы все ветки и тэги) в новый репозиторий
git push --mirror https://github.com/exampleuser/new-repository.git
cd ..
# Удаляем папку с репозиторием