Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from base64 import urlsafe_b64encode as b64encode
import random
random.seed()
pattern = "%%0%dX"
junk_len = 1024
@coffebar
coffebar / gist:e37739ea1f12c2c7c700
Last active August 29, 2015 14:10
php5shop: rename the duplicate path of categories
-- Search for duplicate path:
SELECT c1.id,c1.path,c2.id,c2.path FROM `p5shp_categories` as c1, `p5shp_categories` as c2 WHERE c1.id != c2.id AND c1.path=c2.path;
-- Fix them all
UPDATE `p5shp_categories` SET path = CONCAT( path, CONCAT( '_', (
FLOOR( 1 + RAND( ) *60 ) ))
) WHERE id IN (
SELECT *
@coffebar
coffebar / scan.py
Created September 8, 2015 07:42
Ciphersuite
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sslscan.ui import run
if __name__ == '__main__':
print 'Example of usage:'
print 'scan.py scan --scan=server.ciphers --report=term --tls10 docs.python.org'
run()
@coffebar
coffebar / resolve_security_check_vk.py
Created November 3, 2016 14:04
fix problems with vk.com security check
import requests
import vk
from vk.exceptions import VkAPIError
from re import match, DOTALL
from django.conf import settings
access_token = settings.VK_TOKEN
token_user_id = settings.VK_USER_ID
part_of_phone = settings.VK_SECURITY_CHECK_CODE
@coffebar
coffebar / bit_domain_check_expire.sh
Created October 20, 2017 18:56
Щоб не забути вчасно продовжити домен .bit в блокчейн мережі отримуємо повідомлення в Telegram
#!/bin/bash
# domain google.bit
DOMAIN="google"
DOMAINSPACE="bit"
expires=$(curl "https://peername.net/api/?name=$DOMAIN&namespace=$DOMAINSPACE" 2>&1 | grep expires_in | grep -oE '[0-9]+')
notify_via_telegram()
{
MESSAGE=$1
# your telegram ID
TELEGRAM_CHAT='10000000'
# лимит соединений с ОС Linux
sysctl -a | grep conntrack_max
echo "net.netfilter.nf_conntrack_max=1048576" >> /etc/sysctl.conf
# максимальное количество соединений для работы механизма connection tracking
echo "net.ipv4.netfilter.ip_conntrack_max=16777216" >> /etc/sysctl.conf
# максимальное число открытых сокетов, ждущих соединения
echo "net.core.somaxconn=65535" >> /etc/sysctl.conf
# применить изменения
sysctl -p /etc/sysctl.conf
@coffebar
coffebar / prepare_webpush.sh
Last active March 29, 2018 10:31
Prepare Ubuntu 16.04 server for sending WebPush via php-cron
#!/usr/bin/env bash
PUSHER_USERNAME=webpusher
PUSHER_PASSWORD="1O23%dv5d3}qaa2"
apt update && apt -y upgrade
# install requirements from apt
apt install -y mc htop php-gmp php-mbstring php-curl php-mysql openssl
# add user with ssh
useradd -m -p $PUSHER_PASSWORD $PUSHER_USERNAME
@coffebar
coffebar / todo.txt
Last active September 24, 2021 10:44
How to add ssl cloudflare support to Vesta
cloudflare -> Crypto -> Origin Certificates
Create RSA Certificate
Save Certificate and Private Key
Add it to Vesta with authorities (Cloudflare Origin CA) from https://support.cloudflare.com/hc/en-us/articles/218689638-What-are-the-root-certificate-authorities-CAs-used-with-CloudFlare-Origin-CA-
-----BEGIN CERTIFICATE-----
MIID/DCCAuagAwIBAgIID+rOSdTGfGcwCwYJKoZIhvcNAQELMIGLMQswCQYDVQQG
@coffebar
coffebar / notify_site_changes.sh
Created January 19, 2019 09:30
Watch for regexp result changes on the web page
#!/usr/bin/env bash
function send_telegram {
echo "$1"
}
ver1path="$0.1.cache"
ver2path="$0.2.cache"
ver1=$(cat $ver1path)
curl --silent "https://9gag.com/gag/a2Z7Vpw" 2>&1 | grep 'fbq(' > "$ver2path"
@coffebar
coffebar / unzip_here.sh
Last active March 25, 2019 18:45
Unpack the archives on the fly inside the directory of the script
#!/bin/bash
cd "$(dirname "$0")"
inotifywait --format '%f' -m -e close_write -e moved_to "./" |\
(
while read
do
FILE_TO_UNZIP=$(echo $REPLY | grep --only-matching --ignore-case -P "^.+\.(zip|rar|7z)$")
if [ "$FILE_TO_UNZIP" != "" ]
then