Skip to content

Instantly share code, notes, and snippets.

View makeev's full-sized avatar

Mikhail Makeev makeev

  • Bulgaria, Varna
View GitHub Profile
set synmaxcol=2048 " убираем тормоза подсветки на больших файлах
set nofoldenable " не схлопываем код по умолчанию
set number " показывать номера строк
let g:ackprg = 'ag --nogroup --nocolor --column' " что-то для поиска :Ag
let g:ack_autoclose = 0
" let g:ackpreview = 0
set switchbuf=useopen " открывать превью поиска в том же буфере
set iskeyword+=- " treat dash separated words as a word text object
set mouse=a " Enable your mouse
import asyncio
from thispersondoesnotexist import get_online_person
from thispersondoesnotexist import save_picture
async def f():
picture = await get_online_person() # bytes representation of the image
# Save to a file
from django.utils import timezone
from django.db import models
from django.db.models import CASCADE
class EventsQueryset(models.QuerySet):
def upcoming(self):
now = timezone.now()
return self.filter(date__gte=now).order_by('date')
import base64
from settings import settings
from M2Crypto import RSA
def encrypt(raw):
pub_key_path = settings.PUB_KEY_PATH
write_rsa = RSA.load_pub_key(pub_key_path)
encrypted = write_rsa.public_encrypt(raw, RSA.pkcs1_padding)
@makeev
makeev / create_pkcs7_sign.py
Created March 28, 2016 13:25
Creating a PKCS #7 detached signature of the manifest file for safari push package in python
import M2Crypto
def main():
manifest_path = 'path/to/manifest.json'
signature_path = 'path/to/signature'
# to convert .cer to .pem
# openssl x509 -inform der -in certificate.cer -out certificate.pem
# to combine certificate and key
# cat PushChatCert.pem PushChatKey.pem > ck.pem
charset_table = \
U+00C0->a, U+00C1->a, U+00C2->a, U+00C3->a, U+00C4->a, U+00C5->a, U+00E0->a, U+00E1->a, \
U+00E2->a, U+00E3->a, U+00E4->a, U+00E5->a, U+0100->a, U+0101->a, U+0102->a, U+0103->a, \
U+010300->a, U+0104->a, U+0105->a, U+01CD->a, U+01CE->a, U+01DE->a, U+01DF->a, U+01E0->a, \
U+01E1->a, U+01FA->a, U+01FB->a, U+0200->a, U+0201->a, U+0202->a, U+0203->a, U+0226->a, \
U+0227->a, U+023A->a, U+0250->a, U+04D0->a, U+04D1->a, U+1D2C->a, U+1D43->a, U+1D44->a, \
U+1D8F->a, U+1E00->a, U+1E01->a, U+1E9A->a, U+1EA0->a, U+1EA1->a, U+1EA2->a, U+1EA3->a, \
U+1EA4->a, U+1EA5->a, U+1EA6->a, U+1EA7->a, U+1EA8->a, U+1EA9->a, U+1EAA->a, U+1EAB->a, \
U+1EAC->a, U+1EAD->a, U+1EAE->a, U+1EAF->a, U+1EB0->a, U+1EB1->a, U+1EB2->a, U+1EB3->a, \
U+1EB4->a, U+1EB5->a, U+1EB6->a, U+1EB7->a, U+2090->a, U+2C65->a, \